home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d16 / winbatch.arc / WINBATCH.TXT < prev    next >
Text File  |  1991-05-22  |  214KB  |  7,296 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                   WinBatch
  9.                                                          User's Manual
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.             For IBM (R) PC/XT (R), PC/AT (R), PS/2 (R) and compatibles
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.                                                      Wilson WindowWare
  39.                                        2701 California Ave SW  ste 212
  40.                                                      Seattle, WA 98116
  41.  
  42.                                                  Orders:(800) 762-8383
  43.                                               Support:  (206) 937-9335
  44.                                                  Fax:   (206) 935-7129
  45.  
  46.  
  47.  
  48.  
  49.  
  50.                      Copyright 1988-1991 by Morrie Wilson.
  51.                               All rights reserved.
  52.  
  53.  
  54.  
  55.         No part of this manual may be reproduced or transmitted in any
  56.         form or by any means, electronic or mechanical, including
  57.         photocopying and recording, for any purpose without the
  58.         express written permission of Wilson WindowWare.  Information
  59.         in this document is subject to change without notice and does
  60.         not represent a commitment by Wilson WindowWare.
  61.  
  62.  
  63.         The software described herein is furnished under a license
  64.         agreement.  It is against the law to copy this software under
  65.         any circumstances except as provided by the license agreement.
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.         U.S. Government Restricted Rights
  80.  
  81.         Use, duplication, or disclosure by the Government is subject to
  82.         restrictions as set forth in subdivision (b)(3)(ii) of the Rights
  83.         in Technical Data and Computer Software clause at 252.227-7013.
  84.         Contractor/manufacturer is Wilson WindowWare/2701 California Ave
  85.         SW /ste 212/Seattle, WA 98116
  86.  
  87.  
  88.  
  89.         Trademarks
  90.  
  91.         IBM, PC/XT, PC/AT, and PS/2 are registered trademarks of
  92.         International Business Machines Corporation.
  93.         Microsoft and MS-DOS are registered trademarks of Microsoft
  94.         Corporation.
  95.         Windows, Word for Windows, and Excel are trademarks of Microsoft
  96.         Corporation.
  97.  
  98.         Scramble is a trademark of Diana Gruber.
  99.  
  100.         Command Post, WinBatch, and WinEdit are trademarks of Wilson
  101.         WindowWare.
  102.  
  103.  
  104.         ii
  105.  
  106.                                                                  CONTENTS
  107.  
  108.  
  109.  
  110.  
  111.                                     CONTENTS
  112.  
  113.  
  114.         CONTENTS                                         iii
  115.  
  116.         INTRODUCTION                                     vii
  117.           System Requirements                            vii
  118.           About This Manual                              vii
  119.           Notational Conventions                        viii
  120.           Acknowledgements                              viii
  121.  
  122.         GETTING STARTED                                    1
  123.  
  124.         TUTORIAL                                           2
  125.           WinBatch Basics                                  2
  126.              What is a Batch File?                         2
  127.              Our First WinBatch File                       2
  128.              Functions and Parameters                      3
  129.              Displaying Text                               4
  130.              Getting Input                                 5
  131.              Using Variables                               6
  132.              Making Decisions                              7
  133.              Branching                                     9
  134.           Exploring WinBatch                              11
  135.              Running Programs                             11
  136.              Display and Input                            12
  137.              Manipulating Windows                         13
  138.              Files and Directories                        16
  139.              Handling Errors                              18
  140.              Selection Menus                              19
  141.              Nicer Dialog Boxes                           22
  142.              Running DOS Programs                         24
  143.              Sending Keystrokes to Programs               24
  144.              Our Completed WinBatch File                  25
  145.  
  146.         WINBATCH LANGUAGE                                 27
  147.           Language Components                             27
  148.              Constants                                    27
  149.              Identifiers                                  28
  150.              Variables                                    28
  151.              Keywords Are Reserved                        28
  152.              Operators                                    28
  153.              Precedence and evaluation order              29
  154.              Comments                                     30
  155.              Statements                                   30
  156.              Substitution                                 30
  157.           Function Parameters                             31
  158.           Error Handling                                  31
  159.           The Functions & Statements                      32
  160.              Inputting Information                        32
  161.              Displaying Information                       32
  162.              File Management                              32
  163.              Directory Management                         33
  164.  
  165.  
  166.  
  167.  
  168.                                                                       iii
  169.  
  170.         CONTENTS
  171.  
  172.  
  173.  
  174.              Disk Drive Management                        33
  175.              Window Management                            34
  176.              Program Management                           34
  177.              String Handling                              35
  178.              Arithmetic Functions                         36
  179.              Clipboard Handling                           36
  180.              System Control                               36
  181.  
  182.         WBL FUNCTION REFERENCE                            39
  183.           Introduction                                    39
  184.           Abs                                             40
  185.           AskLine                                         40
  186.           AskYesNo                                        41
  187.           Average                                         41
  188.           Beep                                            42
  189.           Call                                            42
  190.           CallExt                                         42
  191.           Char2Num                                        43
  192.           ClipAppend                                      43
  193.           ClipGet                                         44
  194.           ClipPut                                         45
  195.           DateTime                                        45
  196.           Debug                                           46
  197.           Delay                                           47
  198.           DirChange                                       47
  199.           DirGet                                          48
  200.           DirHome                                         48
  201.           DirItemize                                      49
  202.           DirMake                                         49
  203.           DirRemove                                       50
  204.           DiskFree                                        50
  205.           Display                                         51
  206.           DOSVersion                                      51
  207.           Drop                                            52
  208.           EndSession                                      52
  209.           Environment                                     53
  210.           ErrorMode                                       53
  211.           Execute                                         54
  212.           Exit                                            54
  213.           Exclusive                                       55
  214.           FileClose                                       55
  215.           FileCopy                                        56
  216.           FileDelete                                      56
  217.           FileExist                                       57
  218.           FileExtension                                   58
  219.           FileItemize                                     58
  220.           FileLocate                                      59
  221.           FileMove                                        60
  222.           FileOpen                                        60
  223.           FilePath                                        61
  224.           FileRead                                        61
  225.           FileRename                                      62
  226.           FileRoot                                        63
  227.  
  228.  
  229.  
  230.  
  231.         iv
  232.  
  233.                                                                  CONTENTS
  234.  
  235.  
  236.  
  237.           FileSize                                        63
  238.           FileWrite                                       64
  239.           Goto                                            64
  240.           If_Then                                         64
  241.           IgnoreInput                                     65
  242.           IniRead                                         65
  243.           IniReadPvt                                      66
  244.           IniWrite                                        66
  245.           IniWritePvt                                     67
  246.           IsDefined                                       67
  247.           IsKeyDown                                       68
  248.           IsLicensed                                      68
  249.           IsNumber                                        69
  250.           ItemSelect                                      69
  251.           LastError                                       70
  252.           LogDisk                                         71
  253.           Max                                             71
  254.           Message                                         72
  255.           Min                                             72
  256.           Num2Char                                        73
  257.           ParseData                                       73
  258.           Pause                                           74
  259.           Random                                          74
  260.           Return                                          74
  261.           Run                                             75
  262.           RunHide                                         75
  263.           RunIcon                                         76
  264.           RunZoom                                         77
  265.           SendKey                                         78
  266.           SKDebug                                         79
  267.           StrCat                                          80
  268.           StrCmp                                          80
  269.           StrFill                                         81
  270.           StrFix                                          81
  271.           StriCmp                                         82
  272.           StrIndex                                        83
  273.           StrLen                                          83
  274.           StrLower                                        84
  275.           StrReplace                                      84
  276.           StrScan                                         85
  277.           StrSub                                          86
  278.           StrTrim                                         86
  279.           StrUpper                                        87
  280.           TextBox                                         87
  281.           Version                                         88
  282.           WinActivate                                     88
  283.           WinArrange                                      89
  284.           WinClose                                        89
  285.           WinCloseNot                                     90
  286.           WinConfig                                       91
  287.           WinExist                                        91
  288.           WinGetActive                                    92
  289.           WinHide                                         92
  290.           WinIconize                                      93
  291.  
  292.  
  293.  
  294.  
  295.                                                                         v
  296.  
  297.         CONTENTS
  298.  
  299.  
  300.  
  301.           WinItemize                                      93
  302.           WinPlace                                        94
  303.           WinPosition                                     95
  304.           WinShow                                         96
  305.           WinTitle                                        96
  306.           WinVersion                                      97
  307.           WinWaitClose                                    97
  308.           WinZoom                                         98
  309.           Yield                                           99
  310.  
  311.         APPENDIX A  Predefined Constants                 100
  312.  
  313.         APPENDIX B  Errors                               101
  314.           Minor Errors                                   101
  315.           Moderate Errors                                101
  316.           Fatal Errors                                   102
  317.  
  318.         Index                                            107
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.         vi
  360.  
  361.                                                              INTRODUCTION
  362.  
  363.  
  364.  
  365.  
  366.                                   INTRODUCTION
  367.  
  368.         WinBatch is a new batch language interpreter which brings the
  369.         power of batch language programming to the Windows environment.
  370.         WinBatch files can do pretty much everything the old DOS batch
  371.         files could do, but WinBatch goes far beyond the capabilities of
  372.         the DOS batch language.
  373.  
  374.         WinBatch files can:
  375.  
  376.           *  Run Windows and DOS programs.
  377.           *  Resize and rearrange windows.
  378.           *  Send keystrokes directly to applications.
  379.           *  Display information to the user in various formats.
  380.           *  Prompt the user for input.
  381.           *  Present scrollable file and directory lists.
  382.           *  Copy, move, delete, and rename files.
  383.           *  Read and write files directly.
  384.           *  Perform string and arithmetic operations.
  385.           *  Make branching decisions based upon numerous factors.
  386.  
  387.         And much, much more.
  388.  
  389.         Whether you are creating batch files for others, or looking for a
  390.         way to automate your own work and eliminate the drudgery of
  391.         repetitive tasks, you will find WinBatch to be a powerful,
  392.         versatile, and easy-to-use tool.
  393.  
  394.  
  395.         System Requirements
  396.  
  397.     WinBatch  requires an IBM PC or compatible with a minimum of
  398.         640K memory running Microsoft Windows version 3.0 or higher.
  399.  
  400.  
  401.         About This Manual
  402.  
  403.         This manual is divided into four sections:  First is Getting
  404.         Started (pg. 1), where we tell you how to install the program.
  405.         Then we offer an extensive Tutorial, to get both beginning and
  406.         advanced users quickly up to speed with creating WinBatch files
  407.         (pg. 21).  Then we describe the different elements of the
  408.         WinBatch Language (WBL) (pg. 27).  Finally, there is a
  409.         comprehensive WBL Function Reference (pg. 39), which contains
  410.  
  411.  
  412.  
  413.  
  414.  
  415.                                                                       vii
  416.  
  417.         INTRODUCTION
  418.  
  419.  
  420.  
  421.         detailed information on each of the WinBatch functions and
  422.         statements.
  423.  
  424.  
  425.         Notational Conventions
  426.  
  427.         Throughout this manual, we use the following conventions to
  428.         distinguish elements of text:
  429.  
  430.         ALL-CAPS
  431.           Used for filenames.
  432.  
  433.         Boldface
  434.           Used for important points, programs, function names, and parts
  435.           of syntax that must appear as shown.
  436.  
  437.         system
  438.           Used for menu items as they appear to the user.
  439.  
  440.         Small fixed-width
  441.           Used for batch file sample code.
  442.  
  443.  
  444.         Acknowledgements
  445.  
  446.     WinBatch designed & written by Morrie Wilson.
  447.         User's Manual designed by Richard Merit.
  448.         Written by Richard Merit & Morrie Wilson.
  449.  
  450.         Our thanks to the many beta-testers for their invaluable comments
  451.         & suggestions.
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.         viii
  481.  
  482.                                                           GETTING STARTED
  483.  
  484.  
  485.  
  486.  
  487.                                  GETTING STARTED
  488.  
  489.         WinBatch is quite easy to install.  You will find an appropriate
  490.         diskette in your WinBatch package.  Take the diskette and insert
  491.         it into your floppy drive.  The WinBatch installation program is
  492.         itself a Windows application, so make sure Windows is running.
  493.  
  494.         From the Program Manager, doubleclick on the File Manager icon to
  495.         run it.  When File Manager starts, click on the A: or B: drive
  496.         icon, depending on which floppy drive you used.  A directory tree
  497.         will appear for the WinBatch diskette.  You should see a root
  498.         directory icon.  Doubleclick on this icon and a list of filenames
  499.         will appear.  Find the filename SETUP.EXE and doubleclick on it.
  500.         Follow whatever instructions Setup gives you.
  501.         Setup will create the necessary files and place them into a
  502.         directory it will prompt you for.
  503.  
  504.         As the installation program finishes it will display the
  505.         README.TXT file.  You should take the time to read this file as
  506.         it contains any late-breaking information about your copy of
  507.         WinBatch.
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.                                                                         1
  545.  
  546.         TUTORIAL
  547.  
  548.  
  549.  
  550.  
  551.                                     TUTORIAL
  552.  
  553.  
  554.  
  555.  
  556.         WinBatch Basics
  557.  
  558.  
  559.         What is a Batch File?
  560.  
  561.         A batch file, whether a DOS batch file or a WinBatch file, is
  562.         simply a list of commands for the computer to process.  Any task
  563.         which will be run more than once, or which requires entering many
  564.         commands or even a single complicated command, is a candidate for
  565.         a batch file.  For example, suppose you regularly enter the
  566.         following commands to start Windows:
  567.         First:
  568.  
  569.           cd\windows
  570.  
  571.         then:
  572.  
  573.           win
  574.  
  575.         and then:
  576.  
  577.           cd\
  578.  
  579.         Here, you are changing to the Windows directory, running Windows,
  580.         and then returning to the root directory.  Instead of having to
  581.         type these three commands every time you run Windows, you can
  582.         create a DOS batch file, called WI.BAT, which contains those
  583.         exact same commands:
  584.  
  585.           cd\windows
  586.           win
  587.           cd\
  588.  
  589.         Now, to start Windows, you merely need to type the single command
  590.         WI, which starts the WI.BAT batch file, which runs your three
  591.         commands.
  592.  
  593.         WinBatch files work the same way.
  594.  
  595.  
  596.         Our First WinBatch File
  597.  
  598.         Our first Winbatch file will simply start up our favorite Windows
  599.         application: Solitaire.  First, start up Notepad, or any other
  600.         editor which is capable of saving text in pure ASCII format (may
  601.         we suggest WinEdit, from Wilson WindowWare).  Next, enter the
  602.         following line:
  603.  
  604.           Run("sol.exe","")
  605.  
  606.         Save the file as SOLITARE.WBT.  Now, run SOLITARE.WBT by starting
  607.         or switching to the File Manager, and either moving the cursor to
  608.  
  609.         2
  610.  
  611.                                                                  TUTORIAL
  612.  
  613.  
  614.  
  615.         the file name and pressing Enter, or double-clicking on the file
  616.         name with your mouse.  Presto!  It's Solitaire.
  617.  
  618.         Okay, that wasn't very impressive.  But it did serve to
  619.         illustrate several important WinBatch points.  They are:
  620.  
  621.         1.  WinBatch files must be edited and saved in ASCII format.
  622.  
  623.         2.  WinBatch files should be created with a WBT extension.  When
  624.         WinBatch is first installed, it creates an entry in your WIN.INI
  625.         file which causes files with a WBT extension to be associated
  626.         with WinBatch.  As long as WINBATCH.EXE is located in your DOS
  627.         path, you can place WBT files in any directory and run them by
  628.         simply selecting them.
  629.  
  630.         3.  After you have created a WBT file, you run it by cursoring to
  631.         it and pressing Enter, or double-clicking on it with your mouse
  632.         (you can also add a WBT file to a program group and run it using
  633.         the Program Manager; see your Windows manual for further
  634.         information).  Whatever method you use, we'll use the term Run to
  635.         refer to selecting and running the file.
  636.  
  637.  
  638.         Functions and Parameters
  639.  
  640.         Now, let's look more closely at the line we entered:
  641.  
  642.           Run("sol.exe", "")
  643.  
  644.         The first part, Run, is a WinBatch function.  As you might have
  645.         guessed, its purpose is to run a Windows program.  There are over
  646.         a hundred functions and statements in WinBatch, and each has a
  647.         certain syntax which must be used.  The syntax for all WinBatch
  648.         functions may be found in the WBL Function Reference (pg. 39).
  649.         The entry for Run starts off as follows:
  650.  
  651.         Syntax:
  652.           Run (program-name, parameters)
  653.  
  654.         Parameters:
  655.           "program-name" =  the name of the desired .EXE, .COM, .PIF,
  656.                             .BAT file, or a data file.
  657.           "parameters" =    optional parameters as required by the
  658.                             application.
  659.  
  660.         Like all WinBatch functions, Run is followed by a number of
  661.         parameters, enclosed in parentheses.  Parameters are simply
  662.         additional information which are provided when a particular
  663.         function is used; they made either be required or optional.
  664.         Optional parameters are indicated by being enclosed in brackets.
  665.         In this case, Run has two required parameters: the program name,
  666.         and the parameters which get passed to the application.
  667.         There are several types of parameters which you can use.
  668.         Multiple parameters are separated by commas.  In the example
  669.  
  670.           Run("sol.exe", "")
  671.  
  672.  
  673.  
  674.                                                                         3
  675.  
  676.         TUTORIAL
  677.  
  678.  
  679.  
  680.         "sol.exe" and "" are both string constants.  String constants can
  681.         be identified by the quote marks which delimit (surround) them
  682.         (you may use either double ("), single forward (') or single back
  683.         (`) quote marks as string delimiters; the examples in this manual
  684.         will use double quotes).
  685.  
  686.         You may have noticed how we said earlier that the two parameters
  687.         for the Run function are required, and yet the entry for Run in
  688.         the WBL Function Reference describes the second parameter --
  689.         "parameters" -- as being optional.  Which is correct?  Well, from
  690.         a language standpoint, the second parameter is required.  That
  691.         is, if you omit it, you will get a syntax error, and your batch
  692.         file will not run properly.  However, the program that you are
  693.         running may not need any parameters.  Solitaire, for example,
  694.         does not take any parameters.  The way we handle this in our
  695.         batch file is to specify an empty string -- two quote marks with
  696.         nothing in between -- as the second parameter, as we have done in
  697.         our example above.
  698.  
  699.         To illustrate this further, let's create a WinBatch file called
  700.         EDIT.WBT, containing the following line:
  701.  
  702.           Run("notepad.exe", "")
  703.  
  704.         This is just like our previous file, with only the name of the
  705.         program changed.  Save the file, and run it.  You should now be
  706.         in Notepad.  Now edit the EDIT.WBT file as follows:
  707.  
  708.           Run("notepad.exe", "solitare.wbt")
  709.  
  710.         Save the file, exit Notepad, and run EDIT.WBT again.  You should
  711.         now be in Notepad, with SOLITARE.WBT loaded.  As we've just
  712.         demonstrated, Notepad is an example of a program which can be run
  713.         with or without a file name parameter passed to it by WinBatch.
  714.  
  715.         Before you leave Notepad, modify EDIT.WBT as follows:
  716.  
  717.           ; This is an example of the Run function in WinBatch
  718.           Run("notepad.exe", "solitare.wbt")
  719.  
  720.         The semicolon at the beginning of the first line signifies a
  721.         comment, and causes that line to be ignored.  You can place
  722.         comment lines, and/or blank lines anywhere in your WinBatch
  723.         files.  In addition, you can place a comment on the same line as
  724.         a function by preceding the comment with a semicolon.  For
  725.         example:
  726.  
  727.           Run("sol.exe", "")     ;this is a very useful function
  728.  
  729.         Everything to the right of a semicolon is ignored.  However, if a
  730.         semicolon appears in a string delimited by quotes, it is
  731.         considered part of the string.
  732.  
  733.  
  734.         Displaying Text
  735.  
  736.         Now, let's modify our SOLITARE.WBT file as follows.  You might as
  737.         well use the EDIT.WBT batch file you created earlier to start up
  738.         Notepad:
  739.  
  740.         4
  741.  
  742.                                                                  TUTORIAL
  743.  
  744.  
  745.  
  746.           ; solitare.wbt
  747.           Display(5, "Good Luck!", "Remember ... it's only a game.")
  748.           Run("sol.exe", "")
  749.  
  750.         And run it.  Notice the message box which pops up on the screen
  751.         with words of encouragement.  That's done by the Display function
  752.         in the second line above.  Here's the reference for the Display
  753.         function:
  754.  
  755.         Syntax:
  756.           Display (seconds, title, text)
  757.  
  758.         Parameters:
  759.           seconds = integer seconds to display the message (1-15).
  760.           "title" = Title of the window to be displayed.
  761.           "text" =  Text of the window to be displayed.
  762.         
  763.         Note that the Display function has three parameters.  The first
  764.         parameter -- in our example, 5 -- is the number of seconds which
  765.         the message box will remain on the screen (you can also make the
  766.         box disappear by pressing a key or mouse button).  This is a
  767.         numeric constant, and -- unlike a string constants -- it does not
  768.         need to be enclosed in quotes (although it can be, if you wish,
  769.         as WinBatch will automatically try to convert string variables to
  770.         numeric variables when necessary, and vice versa).  The second
  771.         parameter is the title of the message box, and the third
  772.         parameter is the actual text displayed in the box.  Now, exit
  773.         Solitaire (if you haven't already done so), and edit SOLITARE.WBT
  774.         by placing a semicolon at the beginning of the line with the Run
  775.         function.  This is a handy way to disable, or "comment out,"
  776.         lines in your WinBatch files when you want to modify and test
  777.         only selected segments.  Your SOLITARE.WBT file should look like
  778.         this:
  779.  
  780.           ; solitare.wbt
  781.           Display(5, "Good Luck!", "Remember ... it's only a game.")
  782.           ;Run("sol.exe", "")
  783.  
  784.         Now, experiment with modifying the parameters in the Display
  785.         function.  Try adjusting the value of the first parameter.  If
  786.         you look up Display in the WBL reference section, you will notice
  787.         that the acceptable values for this parameter are 1-15.  If you
  788.         try to use a value outside this range, WinBatch will adjust it to
  789.         "make it fit"; that is, it will treat numbers less than 1 as 1,
  790.         and numbers greater than 15 as 15.  Try it.  Also, try giving it
  791.         a non-integer, such as 2.5, and see what happens.  Play around
  792.         with the text in the two string parameters; try making one, or
  793.         both, empty strings ("").
  794.  
  795.  
  796.         Getting Input
  797.  
  798.         Now, let's look at ways of getting input from a user and making
  799.         decisions based on that input.  The most basic form of input is a
  800.         simple Yes/No response, and, indeed, there is a WinBatch function
  801.         called AskYesNo:
  802.  
  803.  
  804.  
  805.  
  806.                                                                         5
  807.  
  808.         TUTORIAL
  809.  
  810.  
  811.  
  812.         Syntax:
  813.           AskYesNo (title, question)
  814.  
  815.         Parameters
  816.           "title" = title of the question box.
  817.           "question" = question to be put to the user.
  818.  
  819.         Returns:
  820.           (integer) @YES or @NO, depending on the button pressed.
  821.  
  822.         You should be familiar with the standard syntax format by now; it
  823.         shows us that AskYesNo has two required parameters.  The
  824.         Parameters section tells us that these parameters both take
  825.         strings (indicated by the quote marks), and tells us what each of
  826.         the parameters means.
  827.  
  828.         You will notice that there is also a new section here, titled
  829.         Returns.  This selection shows you the possible values that may
  830.         be returned by this function.  All functions return values.  In
  831.         the case of Run and Display, we weren't concerned with the values
  832.         that those functions returned.  But with AskYesNo, the returned
  833.         value is very important, because we will need that information to
  834.         decide how to proceed.  We see that AskYesNo returns an integer
  835.         value.  An integer is simply a non-decimal number, such as 0, 1,
  836.         or 2.  The number 1.5 is not an integer.  We see further that the
  837.         integer value returned by AskYesNo is either @YES or @NO.  @YES
  838.         and @NO are predefined constants in WinBatch.  All predefined
  839.         constants begin with an @ symbol, and we will distinguish them
  840.         further by typing them in all caps.  You will find a list of all
  841.         predefined constants in Appendix A (pg. 100).  Even though the
  842.         words "Yes" and "No" are strings, it is important to remember
  843.         that the predefined constants @YES and @NO are not string
  844.         variables (in fact, they are integers).
  845.  
  846.         Now, let's modify our SOLITARE.WBT file as follows:
  847.  
  848.           AskYesNo("Really?", "Do you really want to play Solitaire
  849.             now?")
  850.           Run("sol.exe", "")
  851.  
  852.         and run it.  You should have gotten a nice dialog box which asked
  853.         if you wanted to play Solitaire, but no matter what you answered,
  854.         it started Solitaire anyway.  This isn't good.  We need a way to
  855.         use the Yes/No response to determine further processing.  First,
  856.         we need to explore the concept and use of variables.
  857.  
  858.  
  859.         Using Variables
  860.  
  861.         A variable is simply a placeholder for a value.  The value that
  862.         the variable stands for can be either a text string (string
  863.         variable) or a number (numeric variable).  If you remember
  864.         Algebra 101, you know that if X=3, then X+X=6.  X is simply a
  865.         numeric variable, which stands here for the number 3.  If we
  866.         change the value of X to 4 (X=4), then the expression X+X is now
  867.         equal to 8.  By the same token, we can say that if Y="morning",
  868.         then "good"+Y="good morning".  If we change the value of Y to
  869.  
  870.  
  871.         6
  872.  
  873.                                                                  TUTORIAL
  874.  
  875.  
  876.  
  877.         "afternoon", then the result of our expression is now "good
  878.         afternoon".  Clear so far?
  879.  
  880.         Now, we know that the AskYesNo function returns a value of either
  881.         @YES or @NO.  What we need to do is create a variable to store
  882.         the value that AskYesNo returns, so that we can use it later on.
  883.         First, we need to give this variable a name.  In WinBatch,
  884.         variable names must begin with a letter, may contain any
  885.         combination of letters or numbers, and may be from 1 to 30
  886.         characters long.  So, let's use a variable called 'response' (we
  887.         will distinguish variable names in this text by typing them in
  888.         all lowercase letters; we will type function and statement names
  889.         starting with a capital letter.  However, in WinBatch, the case
  890.         is irrelevant, so you can use all lowercase, or all uppercase, or
  891.         whatever combination you prefer).  We assign the value returned
  892.         by the AskYesNo function to the variable called 'response' as
  893.         follows:
  894.  
  895.           response = AskYesNo("Really?", "Do you really want to play
  896.             Solitaire now?")
  897.  
  898.         Notice the syntax.  The way that WinBatch process this line is to
  899.         first evaluate the result of the AskYesNo function.  The function
  900.         returns a value of either @YES or @NO.  Then, WinBatch assigns
  901.         this returned value to 'response'.  Therefore, 'response' is now
  902.         equal to @YES or @NO.
  903.  
  904.         Now, all we need is a way to make a decision based upon this
  905.         variable.
  906.  
  907.  
  908.         Making Decisions
  909.  
  910.         WinBatch provides a way to conditionally execute a statement.
  911.         The way this is done is with the If ... Then statement.
  912.         Actually, there are two parts to this construct: If and Then
  913.         (naturally).  The format is:
  914.  
  915.           If condition Then function
  916.  
  917.         The use of If ... Then can be illustrated easily by going back to
  918.         our SOLITARE.WBT file, and making these modifications:
  919.  
  920.           response = AskYesNo("Really?", "Do you really want to play
  921.             Solitaire now?")
  922.           If response == @YES Then Run("sol.exe", "")
  923.  
  924.         As you can see, we are using If ... Then to test whether the
  925.         response to the question posed in AskYesNo is @YES.  If it is
  926.         @YES, then we start Solitaire.  If it's not @YES, then we don't
  927.         start Solitaire.  The rule is: if the condition following the If
  928.         keyword is true, then the function following the Then keyword is
  929.         performed.  If the condition following the If keyword is false,
  930.         then anything following the Then keyword is ignored
  931.         There is something extremely important that you should note about
  932.         the condition following the If keyword: the double equal signs
  933.         (==).  In WinBatch, a single equal sign (=) is an assignment
  934.  
  935.  
  936.  
  937.                                                                         7
  938.  
  939.         TUTORIAL
  940.  
  941.  
  942.  
  943.         operator -- it assigns the value on the right of the equal sign
  944.         to the variable on the left of the equal sign.  As in:
  945.  
  946.           response = AskYesNo("Really?", "Do you really want to play
  947.             Solitaire now?")
  948.  
  949.         This is saying, in English: "Assign the value returned by the
  950.         AskYesNo function to the variable called 'response'."  But in the
  951.         statement:
  952.  
  953.           If response == @YES Then Run("sol.exe", "")
  954.  
  955.         we do not want to assign a new value to response, we merely want
  956.         to test whether it is equal to @YES.  Therefore, we use the
  957.         double equal sign (==), which is the equality operator in
  958.         WinBatch.  The statement above is saying, in English: "If the
  959.         value of the variable called 'response' is equal to @YES, then
  960.         run the program SOL.EXE."  What would happen if we used a single
  961.         equal sign (=) here instead?  Well, since the single equal sign
  962.         (=) is the assignment operator, Winbatch would first assign the
  963.         value @YES to the variable 'response'.  Then, it would perform
  964.         the If function by testing the condition following the keyword
  965.         If.  Since an assignment operation always results in a true
  966.         condition, the condition following the If keyword would always be
  967.         true, and the function following the Then keyword would always be
  968.         performed, regardless of the value of AskYesNo.
  969.  
  970.         If you've become confused now, just remember that a single equal
  971.         sign (=) is an assignment operator, used to assign a value to a
  972.         variable.  A double equal sign (==) is an equality operator, used
  973.         to test whether the values on both sides of the operator are the
  974.         same.  If you ever have a problem with one of your WinBatch
  975.         files, the first thing you check should be whether you've used
  976.         '=' instead of '=='.  We cannot emphasize this too strongly!
  977.         We've seen what happens when the condition following the Then
  978.         keyword is true.  But what happens when it is false?  Remember we
  979.         said that when the If condition is false, the Then function is
  980.         ignored.  There will be times, however when we want to perform an
  981.         alternate action in this event.  For example, suppose we want to
  982.         display a message if the user decides he or she doesn't want to
  983.         play Solitaire.  We could say:
  984.  
  985.           response = AskYesNo("Really?", "Do you really want to play
  986.             Solitaire now?")
  987.           If response == @YES Then Run("sol.exe", "")
  988.           If response == @NO Then Display(5, "Game Canceled", "Smart
  989.             move ... I think the boss is standing behind you.")
  990.  
  991.         In this case there are two If statements being evaluated, with
  992.         one and only one of them possibly being true (unless the user
  993.         selected the Cancel button, which would abort the batch file
  994.         entirely).  However, this is not very efficient from a processing
  995.         point of view.  Furthermore, what would happen if you had several
  996.         functions you wanted to perform if the user answered 'Yes'?  You
  997.         would end up with something unwieldy, like:
  998.  
  999.  
  1000.  
  1001.  
  1002.         8
  1003.  
  1004.                                                                  TUTORIAL
  1005.  
  1006.  
  1007.  
  1008.           response = AskYesNo("Really?", "Do you really want to play
  1009.             Solitaire now?")
  1010.           If response == @YES Then Display(5, "", "On your mark ...")
  1011.           If response == @YES Then Display(5, "", "Get set ...")
  1012.           If response == @YES Then Display(5, "", "Go!")
  1013.           If response == @YES Then Run("sol.exe", "")
  1014.  
  1015.         Clearly, there must be a better way of handling this.
  1016.  
  1017.  
  1018.         Branching
  1019.  
  1020.         Enter the Goto function.  Goto, in combination with If ... Then,
  1021.         gives you complete control over the flow of control in your
  1022.         WinBatch files.  Goto does exactly what it says -- it causes the
  1023.         flow of control to go to another point in the batch file.  You
  1024.         must specify where you want the flow of control to be
  1025.         transferred, and you must mark this point with a label.  A label
  1026.         is simply a destination address.  The form of the Goto function
  1027.         is:
  1028.  
  1029.           Goto label
  1030.  
  1031.         where label is an identifier that you specify.  The same rules
  1032.         apply to label names as to variable names (the first character
  1033.         must be a letter, the label name may consist of any combination
  1034.         of letters and numbers, and the label name may be from 1 to 30
  1035.         characters long).  In addition, the label is preceded by a colon
  1036.         at the point where it is being used as a destination address.
  1037.         Here's an example:
  1038.  
  1039.           response = AskYesNo("Really?", "Do you really want to play
  1040.             Solitaire now?")
  1041.           If response == @NO Then Goto quit
  1042.           Display(5, "", "On your mark ...")
  1043.           Display(5, "", "Get set ...")
  1044.           Display(5, "", "Go!")
  1045.           Run("sol.exe", "")
  1046.           :quit
  1047.  
  1048.         If the If condition is true (that is, the user answered 'No'),
  1049.         then the Goto function is performed.  The Goto statement is
  1050.         saying, in English "go to the line marked ':quit' and continue
  1051.         processing from there."  Notice how the label 'quit' is preceded
  1052.         by colon on the last line, but not on the line with the Goto
  1053.         function.  This is important.  Although you can have multiple
  1054.         lines in your batch file which say 'Goto quit', you can have only
  1055.         one line marked ':quit'.  Of course, you can use many different
  1056.         labels in a batch file, just as you can use many different
  1057.         variables, as long as each has a unique name.  For example:
  1058.  
  1059.           response = AskYesNo("Really?", "Do you really want to play
  1060.             Solitaire now?")
  1061.           If response == @NO Then Goto quit
  1062.           Display(5, "", "On your mark ...")
  1063.           Display(5, "", "Get set ...")
  1064.           Display(5, "", "Go!")
  1065.  
  1066.  
  1067.                                                                         9
  1068.  
  1069.         TUTORIAL
  1070.  
  1071.  
  1072.  
  1073.           Run("sol.exe", "")
  1074.           Goto done
  1075.           :quit
  1076.           Display(5, "Game Canceled", "Smart move ... I think the boss
  1077.             is standing behind you.")
  1078.           :done
  1079.  
  1080.         This is a little more complicated.  It uses two labels, 'quit'
  1081.         and 'done'.  If the user answers 'No', then the If condition is
  1082.         true, control passes to the line marked ':quit', and a message is
  1083.         displayed.  If, on the other hand, the user answers 'Yes', then
  1084.         the If condition is false, and the 'Goto quit' line is ignored.
  1085.         Instead, the next four lines are processed, and then the 'Goto
  1086.         done' line is unconditionally performed.  The purpose of this
  1087.         line is to bypass the Display line which follows by transferring
  1088.         control to the end of the batch file.  There is another way to
  1089.         keep your batch file processing from "falling through" to
  1090.         unwanted lines at the end of a program, and that is with the Exit
  1091.         function.  Exit causes a batch file to end immediately.  So, for
  1092.         example, we could rewrite the above batch file as follows:
  1093.  
  1094.           response = AskYesNo("Really?", "Do you really want to play
  1095.             Solitaire now?")
  1096.           If response == @NO Then Goto quit
  1097.           Display(5, "", "On your mark ...")
  1098.           Display(5, "", "Get set ...")
  1099.           Display(5, "", "Go!")
  1100.           Run("sol.exe", "")
  1101.           Exit
  1102.           :quit
  1103.           Display(5, "Game Canceled", "Smart move ... I think the boss
  1104.             is standing behind you.")
  1105.  
  1106.         Since the Run function is the last thing we want to do if the
  1107.         user answers 'Yes', the Exit function simply ends the program at
  1108.         that point.  Note that we could put an Exit function at the end
  1109.         of the program as well, but it isn't necessary.  An Exit is
  1110.         implied at the end of a WinBatch program.
  1111.  
  1112.  
  1113.         This concludes the first part of our tutorial.  You now have the
  1114.         building blocks you need to create useful WinBatch files.  In the
  1115.         second part, which follows, we will look at a some of the
  1116.         WinBatch functions which are available for your use.
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.         10
  1129.  
  1130.                                                                  TUTORIAL
  1131.         Exploring WinBatch
  1132.  
  1133.         What follows is just a sample of the functions and statements
  1134.         available in WinBatch.  These should be sufficient to begin
  1135.         creating versatile and powerful batch files.  For complete
  1136.         information on these and all WinBatch functions and statements,
  1137.         refer to the WBL Function Reference (pg. 39).
  1138.  
  1139.  
  1140.         Running Programs
  1141.  
  1142.         There are three functions which you can use to start an
  1143.         application, each of which shares a common syntax:
  1144.  
  1145.  
  1146.         Run (program-name, parameters)
  1147.  
  1148.         We've already seen the Run function.  This function starts a
  1149.         program in a "normal" window.  Windows decides where to place the
  1150.         application's  window on the screen.
  1151.         Example:
  1152.  
  1153.            Run("Notepad.exe", "myfile.txt")
  1154.  
  1155.         If the program has an EXE extension, its extension may be
  1156.         omitted:
  1157.  
  1158.            Run("Notepad", "myfile.txt")
  1159.  
  1160.         Also, you can "run" data files if they have an extension in
  1161.         WIN.INI which is associated with a program.  So, if TXT files are
  1162.         associated with Notepad:
  1163.  
  1164.            Run("myfile.txt", "")
  1165.  
  1166.         would start Notepad, using the file MYFILE.TXT.
  1167.  
  1168.         When you specify a file to run, WinBatch looks first in the
  1169.         current directory, and then in the directories on your DOS Path.
  1170.         If the file is not found, WinBatch will return an error.  You can
  1171.         also specify a full path name for WinBatch to use, as in:
  1172.  
  1173.            Run("c:\windows\apps\winedit.exe", "")
  1174.  
  1175.  
  1176.         RunZoom (program-name, parameters)
  1177.  
  1178.         RunZoom is like Run, but it starts a program as a full-screen
  1179.         window.
  1180.  
  1181.         Example:
  1182.  
  1183.            RunZoom("excel", "bigsheet.xls")
  1184.  
  1185.  
  1186.         RunIcon (program-name, parameters)
  1187.  
  1188.         RunIcon starts a program as an icon at the bottom of the screen.
  1189.         Example:
  1190.  
  1191.            RunIcon("clock", "")
  1192.  
  1193.  
  1194.                                                                        11
  1195.  
  1196.         TUTORIAL
  1197.  
  1198.         Display and Input
  1199.  
  1200.         Here we have functions which display information to the user and
  1201.         prompt the user for information, plus a couple of relevant system
  1202.         functions.
  1203.  
  1204.         Display (seconds, title, text)
  1205.  
  1206.         Displays a message to the user for a specified time.  The message
  1207.         will disappear after the time expires, or after any keypress or
  1208.         mouse click.
  1209.         Example:
  1210.  
  1211.            Display(2, "", "Loading Solitaire now")
  1212.  
  1213.         Message (title, text)
  1214.  
  1215.         This command displays a message box with a title and text you
  1216.         specify, until the user presses the OK button.
  1217.  
  1218.         Example:
  1219.  
  1220.            Message("Sorry", "That file cannot be found")
  1221.  
  1222.         Pause (title, text)
  1223.  
  1224.         This command is similar to Message, except an exclamation-point
  1225.         icon appears in the message box, and the user can press OK or
  1226.     Cancel.  If the user presses Cancel, the batch file exits.  Example:
  1227.  
  1228.            Pause("Delete Backups", "Last chance to stop!")
  1229.            ;if batch file gets this far, the user pressed OK
  1230.            FileDelete("*.bak")
  1231.  
  1232.         AskYesNo (title, question)
  1233.  
  1234.         Displays a dialog box with a given title, which presents the user
  1235.         with three buttons: Yes, No, and Cancel.  If the user selects the
  1236.         Cancel button, the batch file is terminated.
  1237.  
  1238.         Example:
  1239.  
  1240.            response = AskYesNo("End Session", "Are you sure you want to
  1241.              leave Windows?"
  1242.  
  1243.         AskLine (title, prompt, default)
  1244.  
  1245.         Displays a dialog box with a given title, which prompts the user
  1246.         for a line of input.  Returns the default if the user just
  1247.         presses the OK button.
  1248.         Example:
  1249.  
  1250.            yourfile = AskLine("Edit File", "Filename:", "newfile.txt")
  1251.            Run("notepad", yourfile)
  1252.  
  1253.         If you specify a default entry (in this case, NEWFILE.TXT), it
  1254.         will appear in the response box, and will be replaced with
  1255.         whatever the user types.
  1256.  
  1257.         Beep
  1258.  
  1259.         Beeps once.
  1260.         12
  1261.  
  1262.                                                                  TUTORIAL
  1263.  
  1264.           Beep
  1265.  
  1266.         And if one beep isn't enough for you:
  1267.  
  1268.           Beep
  1269.           Beep
  1270.           Beep
  1271.  
  1272.  
  1273.         Delay (seconds)
  1274.  
  1275.         Pauses batch file execution.
  1276.         The Delay function lets you suspend batch file processing for 1
  1277.         to 15 seconds.  Again, you can use multiple occurrences for a
  1278.         longer delay:
  1279.  
  1280.           Delay(15)
  1281.           Delay(15)
  1282.  
  1283.         Will insert a 30-second pause.
  1284.  
  1285.  
  1286.         Manipulating Windows
  1287.  
  1288.         There are a large number of functions which allow you to manage
  1289.         the windows on your desktop.  Here are some of them:
  1290.  
  1291.  
  1292.         WinZoom (partial-windowname)
  1293.  
  1294.         Maximizes an application window to full-screen.
  1295.  
  1296.  
  1297.         WinIconize (partial-windowname)
  1298.  
  1299.         Turns an application window into an icon.
  1300.  
  1301.  
  1302.         WinShow (partial-windowname)
  1303.  
  1304.         Shows a window in its "normal" state.
  1305.  
  1306.  
  1307.         These three functions are used to modify the size of an already-
  1308.         running window.  WinZoom is the equivalent of selecting Maximize
  1309.         from a window's control (space-bar) menu, WinIconize is the same
  1310.         as selecting Minimize, and WinShow has the same effect as
  1311.         selecting Restore.
  1312.  
  1313.         The window that you are performing any of these functions on does
  1314.         not have to be the active window.  If the specified window is in
  1315.         the background, and the WinZoom or WinShow function causes the
  1316.         size of the window to change, then the window will be brought to
  1317.         the foreground.  The WinZoom function has no effect on a window
  1318.         which is already maximized, and WinShow has no effect on an
  1319.         already-"normal" window.
  1320.  
  1321.         Each of these functions takes a partial windowname as a
  1322.         parameter.  The "windowname" is the name which appears in the
  1323.         title bar at the top of the window.  You can specify the full
  1324.         name if you wish, but it may often be advantageous not to have to
  1325.                                                                        13
  1326.  
  1327.         TUTORIAL
  1328.  
  1329.  
  1330.  
  1331.         do so.  For example, if you are editing the file SOLITARE.WBT in
  1332.         a Notepad window open, the windowname will be
  1333.  
  1334.           Notepad - SOLITARE.WBT
  1335.  
  1336.         You probably don't want to have to hard-code this name into your
  1337.         batch file:
  1338.  
  1339.           WinZoom("Notepad - SOLITARE.WBT")
  1340.  
  1341.         Instead, you can specify the partial windowname 'Notepad':
  1342.  
  1343.           WinZoom("Notepad")
  1344.  
  1345.         If you have more than one Notepad window open, WinBatch will use
  1346.         the first one it finds.
  1347.  
  1348.         Note that WinBatch matches the partial windowname starting with
  1349.         the first character, so that while
  1350.  
  1351.           WinZoom("Note")
  1352.  
  1353.         would be correct,
  1354.  
  1355.           WinZoom("pad")
  1356.  
  1357.         would not result in a match.
  1358.  
  1359.         Also, be aware that the case of the title (upper or lower) is
  1360.         significant, so:
  1361.  
  1362.           WinZoom("notepad")
  1363.  
  1364.         would be invalid.
  1365.  
  1366.         WinActivate (partial-windowname)
  1367.  
  1368.         Makes an application window the active window.
  1369.         This function makes a currently-open window the active window.
  1370.         If the specified window is an icon, it will be restored to normal
  1371.         size; otherwise, its size will not be changed.
  1372.  
  1373.  
  1374.         WinClose (partial-windowname)
  1375.  
  1376.         Closes an application window.
  1377.  
  1378.  
  1379.         WinCloseNot (partial-windowname [, partial-windowname]...)
  1380.  
  1381.         Closes all application windows except those specified.
  1382.  
  1383.         This function lets you close all windows except the one(s) you
  1384.         specify.  For example:
  1385.  
  1386.           WinCloseNot("Program Man")
  1387.  
  1388.         would leave only the Program Manager open, and:
  1389.  
  1390.           WinCloseNot("Program Man, Solit")
  1391.         14
  1392.  
  1393.                                                                  TUTORIAL
  1394.  
  1395.  
  1396.  
  1397.         would leave the Program Manager and Solitaire windows open.
  1398.  
  1399.  
  1400.         WinWaitClose (partial-windowname)
  1401.  
  1402.         Waits until an application window is closed.
  1403.         This function causes your WinBatch file to pause until you have
  1404.         manually closed a specified window.  This is a very convenient
  1405.         way to have a WinBatch file open several windows sequentially,
  1406.         without having unnecessary windows open all over your desktop.
  1407.         For example:
  1408.  
  1409.           RunZoom("invoices.xls", "") ;balance the books
  1410.           WinWaitClose("Microsoft Ex")  ;wait till Excel closed
  1411.           RunZoom("sol", "")          ;you deserve a break
  1412.           WinWaitClose("Solitaire")     ;wait until Sol closed
  1413.           Run("winword", "agenda.doc")  ;more paperwork
  1414.           WinWaitClose("Microsoft Wor") ;wait until W4W closed
  1415.           Run("clock","")             ;lunchtime yet?
  1416.  
  1417.         During the time that the batch file is suspended, the WinBatch
  1418.         icon will remain at the bottom of your screen.  You can cancel
  1419.         the batch file at any time by selecting the icon and then
  1420.         selecting "Terminate" from the menu.
  1421.  
  1422.  
  1423.         WinExist (partial-windowname)
  1424.  
  1425.         Tells if Window exists.
  1426.  
  1427.         This function returns @TRUE or @FALSE, depending on whether a
  1428.         matching window can be found.  This gives you a very handy method
  1429.         of insuring that only one copy of a given window will be open at
  1430.         a time.
  1431.  
  1432.         If you've been following this tutorial faithfully from the
  1433.         beginning, you probably have several copies of Solitaire running
  1434.         at the moment.  You can check by pressing Ctrl-Esc now.  You say
  1435.         you've got 5 Solitaire windows open?  Okay, close them all.  Now,
  1436.         let's modify our SOLITARE.WBT file.  First, trim out the excess
  1437.         lines so that it looks like this:
  1438.  
  1439.           Run("sol.exe", "")
  1440.  
  1441.         Now, let's use the WinExist function to make sure that WinBatch
  1442.         only starts Solitaire if it isn't already running:
  1443.  
  1444.           If WinExist("Solitaire") == @FALSE Then Run("sol.exe", "")
  1445.  
  1446.         And this should work fine.  Run SOLITARE.WBT twice now, and see
  1447.         what happens.  The first time you run it, it should start
  1448.         Solitaire; the second (and subsequent) time, it should not do
  1449.         anything.
  1450.  
  1451.         However, it's quite likely that you want the batch file to do
  1452.         something if Solitaire is already running -- namely, bring the
  1453.         Solitaire window to the foreground.  This can be accomplished
  1454.  
  1455.  
  1456.  
  1457.                                                                        15
  1458.  
  1459.         TUTORIAL
  1460.  
  1461.  
  1462.  
  1463.         easily by using the WinActivate function, along with a couple of
  1464.         Goto statements, as follows:
  1465.  
  1466.           If WinExist("Solitaire") == @FALSE Then Goto open
  1467.           WinActivate("Solitaire")
  1468.           Goto loaded
  1469.           :open
  1470.           Run("sol.exe", "")
  1471.           :loaded
  1472.  
  1473.         Note that we can change this to have WinExist check for a 'True'
  1474.         value instead, by modifying the structure of the batch file, as
  1475.         follows:
  1476.  
  1477.           If WinExist("Solitaire") == @TRUE Then Goto activate
  1478.           Run("sol.exe", "")
  1479.           Goto loaded
  1480.           :activate
  1481.           WinActivate("Solitaire")
  1482.           :loaded
  1483.  
  1484.         Either format is perfectly correct, and the choice of which to
  1485.         use is merely a matter of personal style.  The result is exactly
  1486.         the same.
  1487.  
  1488.  
  1489.         EndSession ( )
  1490.  
  1491.         Ends the current Windows session.
  1492.         This does exactly what it says.  It will not ask any questions,
  1493.         so you may want to build in a little safety net:
  1494.  
  1495.           Sure = AskYesNo("End Session", "Are you sure you want to exit
  1496.             Windows?")
  1497.           If Sure == @YES Then EndSession()
  1498.  
  1499.  
  1500.         Files and Directories
  1501.  
  1502.  
  1503.         DirChange (pathname)
  1504.  
  1505.         Changes the directory to the pathname specified.
  1506.         Use this function when you want to run a program which must be
  1507.         started from its own directory.  'Pathname' may optionally
  1508.         include a drive letter.
  1509.  
  1510.         Example:
  1511.  
  1512.            DirChange("c:\windows\winword")
  1513.            Run("winword.exe", "")
  1514.  
  1515.  
  1516.         DirGet ( )
  1517.  
  1518.         Gets the Current Working Directory.
  1519.  
  1520.         This function is especially useful when used in conjunction with
  1521.         DirChange, to save and then return to the current directory.
  1522.  
  1523.         16
  1524.  
  1525.                                                                  TUTORIAL
  1526.  
  1527.  
  1528.  
  1529.         Example:
  1530.  
  1531.           origdir = DirGet()
  1532.           DirChange("c:\windows\winword")
  1533.           Run("winword.exe", "")
  1534.           DirChange(origdir)
  1535.  
  1536.  
  1537.         FileExist (filename)
  1538.  
  1539.         Determines if a file exists.
  1540.  
  1541.         This function will return @TRUE if the specified file exists, and
  1542.         @FALSE if it doesn't exist.
  1543.         Example:
  1544.  
  1545.            If FileExist("win.bak") == @FALSE Then FileCopy("win.ini",
  1546.              "win.bak")
  1547.            Run("notepad.exe", "win.ini")
  1548.  
  1549.  
  1550.         FileCopy (from-list, to-file, warning)
  1551.  
  1552.         Copies files.
  1553.  
  1554.         If warning is @TRUE, WinEdit will pop up a dialog box warning you
  1555.         if you are about to overwrite an existing file, and giving you an
  1556.         opportunity to change your mind.  If warning is @FALSE, it won't.
  1557.         Example:
  1558.  
  1559.            FileCopy("cmdpost.cpm", "*.sav", @TRUE)
  1560.            Run("notepad.exe", "cmdpost.cpm")
  1561.  
  1562.         The wildcard (*) will cause cmdpost.cpm to be copied as
  1563.         cmdpost.sav.
  1564.  
  1565.  
  1566.         FileDelete (file-list)
  1567.  
  1568.         Deletes files.
  1569.  
  1570.         Example:
  1571.  
  1572.            If FileExist("win.bak") == @TRUE Then FileDelete("win.bak")
  1573.  
  1574.  
  1575.         FileRename (from-list, to-file)
  1576.  
  1577.         Renames files to another set of names.
  1578.  
  1579.  
  1580.         We can illustrate the use of the WinBatch file functions with a
  1581.         typical batch file application.  Our word processor saves a
  1582.         backup copy of each document with a BAK extension, but we want a
  1583.         larger safety net when editing important files.  We want to keep
  1584.         the five most recent versions of the Winbatch manual.  Here is
  1585.         our batch file:
  1586.  
  1587.  
  1588.  
  1589.                                                                        17
  1590.  
  1591.         TUTORIAL
  1592.  
  1593.  
  1594.  
  1595.           If FileExist("winbatch.bak") == @TRUE Then Goto backup
  1596.           :edit
  1597.           Run("winword.exe", "winbatch.doc")
  1598.           Exit
  1599.           :backup
  1600.           FileDelete("winbatch.bk5")
  1601.           FileRename("winbatch.bk4", "winbatch.bk5)
  1602.           FileRename("winbatch.bk3", "winbatch.bk4)
  1603.           FileRename("winbatch.bk2", "winbatch.bk3)
  1604.           FileRename("winbatch.bk1", "winbatch.bk2)
  1605.           FileRename("winbatch.bak", "winbatch.bk1)
  1606.           Goto edit
  1607.  
  1608.         If the file WINBATCH.BAK exists, it means that we have made a
  1609.         change to WINBATCH.DOC.  So, before we start editing, we delete
  1610.         the oldest backup copy, and perform several FileRename functions,
  1611.         until eventually WINBATCH.BAK becomes WINBATCH.BK1.  Notice how
  1612.         the flow of control moves to the line labeled ':backup', and then
  1613.         back to the line labeled ':edit', and how we terminate processing
  1614.         with the Exit statement.  If we did not include the Exit
  1615.         statement, the batch file would continue in an endless loop.
  1616.         However, this batch file still isn't quite right.  What would
  1617.         happen if the file WINBATCH.BK5 didn't exist?  In the DOS batch
  1618.         language, the command would return an error and processing would
  1619.         continue.  But in WinBatch, the error would be fatal, and cause
  1620.         the batch file to abort.
  1621.  
  1622.         There are two ways that we can handle this.  We could use an If
  1623.         FileExist test before every file operation, and test the returned
  1624.         value for a @TRUE before proceeding.  But this would be very
  1625.         clumsy, even with such a small batch file.
  1626.  
  1627.  
  1628.         Handling Errors
  1629.  
  1630.         Luckily, there is a WinBatch system function to help us here:
  1631.         ErrorMode.  The ErrorMode function determines what happens if an
  1632.         error occurs during batch file processing.  Here's the syntax:
  1633.  
  1634.  
  1635.         ErrorMode (mode)
  1636.  
  1637.         Specifies how to handle errors.
  1638.  
  1639.         Parameters:
  1640.           "mode" =  @CANCEL, @NOTIFY, or @OFF.
  1641.  
  1642.         Returns:
  1643.           (integer) previous error setting.
  1644.  
  1645.         Use this command to control the effects of runtime errors.  The
  1646.         default is @CANCEL, meaning the execution of the batch file will
  1647.         be canceled for any error.
  1648.  
  1649.         @CANCEL:  All runtime errors will cause execution to be
  1650.         canceled.  The user will be notified which error occurred.
  1651.  
  1652.  
  1653.  
  1654.  
  1655.         18
  1656.  
  1657.                                                                  TUTORIAL
  1658.  
  1659.  
  1660.  
  1661.         @NOTIFY:  All runtime errors will be reported to the user, and
  1662.         they can choose to continue if it isn't fatal.
  1663.  
  1664.         @OFF:  Minor runtime errors will be suppressed. Moderate and
  1665.         fatal errors will be reported to the user.  User has the option
  1666.         of continuing if the error is not fatal.
  1667.  
  1668.         As you can see, the default mode is @CANCEL, and it's a good idea
  1669.         to leave it like this.  However, it is quite reasonable to change
  1670.         the mode for sections of your batch files where you anticipate
  1671.         errors occurring.  This is just what we've done in our modified
  1672.         batch file:
  1673.  
  1674.           If FileExist("winbatch.bak") == @TRUE Then Goto backup
  1675.           :edit
  1676.           Run("winword.exe", "winbatch.doc")
  1677.           Exit
  1678.           :backup
  1679.           ErrorMode(@OFF)
  1680.           FileDelete("winbatch.bk5")
  1681.           FileRename("winbatch.bk4", "winbatch.bk5)
  1682.           FileRename("winbatch.bk3", "winbatch.bk4)
  1683.           FileRename("winbatch.bk2", "winbatch.bk3)
  1684.           FileRename("winbatch.bk1", "winbatch.bk2)
  1685.           FileRename("winbatch.bak", "winbatch.bk1)
  1686.           ErrorMode(@CANCEL)
  1687.           Goto edit
  1688.  
  1689.         Notice how we've used ErrorMode(@OFF) to prevent errors from
  1690.         aborting the batch file, and then used ErrorMode(@CANCEL) at the
  1691.         end of the backup section to change back to the default mode.
  1692.         This is good practice.
  1693.  
  1694.  
  1695.         Selection Menus
  1696.  
  1697.         So far, whenever we have needed to use a file name, we have hard-
  1698.         coded it into our batch files.  For example:
  1699.  
  1700.           Run("notepad.exe", "agenda.txt")
  1701.  
  1702.         Naturally, there should be a way to get this information from the
  1703.         user "on the fly", so that we wouldn't have to write hundreds of
  1704.         different batch files.  And there is a way.  Two ways, actually.
  1705.         Consider, first, a function that we have already seen, the
  1706.         AskLine function:
  1707.  
  1708.           file = AskLine("", "Enter Filename to edit?", "")
  1709.           Run("notepad.exe", file)
  1710.  
  1711.         This will prompt the user for a filename, and start Notepad using
  1712.         that file.
  1713.  
  1714.         There are only three problems with this approach.  First, the
  1715.         user might not remember the name of the file.  Second, the user
  1716.         might enter the name incorrectly.  And finally, modern software
  1717.  
  1718.  
  1719.  
  1720.  
  1721.                                                                        19
  1722.  
  1723.         TUTORIAL
  1724.  
  1725.  
  1726.  
  1727.         is supposed to be sophisticated enough to handle these things the
  1728.         right way.  And WinBatch certainly can.
  1729.  
  1730.         There are two new functions we need to use for our file selection
  1731.         routine: FileItemize and ItemSelect.
  1732.  
  1733.  
  1734.         FileItemize (file-list)
  1735.  
  1736.         Returns a space-delimited list of files.
  1737.  
  1738.         This function compiles a list of filenames and separates the
  1739.         names with spaces.  There are several variations we can use:
  1740.  
  1741.           FileItemize("*.doc")
  1742.  
  1743.         would give us a list of all files in the current directory with a
  1744.         DOC extension,
  1745.  
  1746.           FileItemize("*.com *.exe")
  1747.  
  1748.         would give us a list of all files in the current directory with a
  1749.         COM or EXE extension, and
  1750.  
  1751.           FileItemize("*.*")
  1752.  
  1753.         would give us a list of all files in the current directory.
  1754.  
  1755.         Of course, we need to be able to use this file list, and for that
  1756.         we use:
  1757.  
  1758.  
  1759.         ItemSelect (title, list, delimiter)
  1760.  
  1761.         Displays a listbox filled with items from a list you specify in a
  1762.         string.  The items are separated in your string by a delimiter
  1763.         character.
  1764.  
  1765.         This function actually displays the list box.  Remember that
  1766.         FileItemize returns a file list delimited by spaces, which would
  1767.         look something like this:
  1768.  
  1769.           file1.doc file2.doc file3.doc
  1770.  
  1771.         When we use ItemSelect, we need to tell it that the delimiter is
  1772.         a space.  We do this as follows:
  1773.  
  1774.            textfiles = FileItemize("*.doc *.txt")
  1775.            yourfile = ItemSelect("Select a file to edit", textfiles, "")
  1776.            run("notepad.exe", yourfile)
  1777.  
  1778.         First, we use FileItemize to build a list of filenames with DOC
  1779.         and TXT extensions.  We assign this list to the variable
  1780.         'textfiles'.  Then, we use the ItemSelect function to build a
  1781.         list box, passing it the variable 'textfiles' as its second
  1782.         parameter.  The third parameter we use for ItemSelect is simply a
  1783.         space with quote marks around it; this tells ItemSelect that the
  1784.         variable 'textfiles' is delimited by spaces.  Note that this is
  1785.         different from the empty string that we've spoken about earlier -
  1786.  
  1787.         20
  1788.  
  1789.                                                                  TUTORIAL
  1790.  
  1791.  
  1792.  
  1793.         - you must include a space between the quote marks.  Finally, we
  1794.         assign the value returned by the ItemSelect function to the
  1795.         variable 'yourfile', and run Notepad using that file.
  1796.  
  1797.         How does ItemSelect get a file name?  As we said, it pops up a
  1798.         list box with all the files returned by the FileSelect function.
  1799.         Then, you highlight a file, using either the cursor keys or a
  1800.         mouse, and select it by pressing Enter, double-clicking on the
  1801.         file, or clicking on the OK button.  If you run the above
  1802.         example, you'll see it more easily than we can explain it in
  1803.         words.
  1804.  
  1805.         If the user presses Enter or clicks on the OK button without a
  1806.         file being highlighted, ItemSelect returns an empty string.  If
  1807.         you want, you can test for this condition:
  1808.  
  1809.            textfiles = FileItemize("*.doc *.txt")
  1810.            :retry
  1811.            yourfile = ItemSelect("Select a file to edit", textfiles, "")
  1812.            if yourfile == "" Then Goto retry
  1813.            run("notepad.exe", yourfile)
  1814.  
  1815.  
  1816.         DirItemize (dir-list)
  1817.  
  1818.         Returns a space-delimited list of directories.
  1819.  
  1820.         This function works like FileItemize, but instead of returning a
  1821.         list of files, it returns a list of directories.  Remember that
  1822.         we said FileItemize only lists files in the current directory.
  1823.         Often, we want to be able to use files in other directories as
  1824.         well.  We can do this by first selecting the appropriate
  1825.         directory, using DirItemize and ItemSelect:
  1826.  
  1827.           DirChange("\")
  1828.           subdirs = DirItemize("*")
  1829.           targdir = ItemSelect("Select dir", subdirs, " ")
  1830.           DirChange(targdir)
  1831.           files = FileItemize("*.*")
  1832.           file = ItemSelect("Select file", files, " ")
  1833.           Run("notepad.exe", file)
  1834.  
  1835.         First we change to the root directory.  Then we use the
  1836.         DirItemize function to get a list of all the subdirectories off
  1837.         of root.  Next, we use ItemSelect to give us a list box of
  1838.         directories to select from.  Finally, we change to the selected
  1839.         directory, and use FileItemize and ItemSelect to pick a file.
  1840.         This batch file works, but needs to be polished up a bit.  What
  1841.         happens if the file we want is in the \WIN\BATCH directory?  Our
  1842.         batch file doesn't go more than one level deep from root.  We
  1843.         want  to continue down the directory tree, but we also need a way
  1844.         of telling when we're at the end of a branch.  As it happens,
  1845.         there is such a way: DirItemize will return an empty string if
  1846.         there are no directories to process.  Given this knowledge, we
  1847.         can set up a loop to test when we are at the lowest level:
  1848.  
  1849.  
  1850.  
  1851.                                                                        21
  1852.  
  1853.         TUTORIAL
  1854.  
  1855.  
  1856.  
  1857.           DirChange("\")
  1858.           :getdir
  1859.           subdirs = DirItemize("*")
  1860.           If subdirs == "" Then Goto getfile
  1861.           targdir = ItemSelect("Select dir (OK for current)", subdirs, "")
  1862.           If targdir == "" Then Goto getfile
  1863.           DirChange(targdir)
  1864.           Goto getdir
  1865.           :getfile
  1866.           files = FileItemize("*.*")
  1867.           file = ItemSelect("Select file", files, " ")
  1868.           if file == "" then goto getfile
  1869.           Run("notepad.exe", file)
  1870.  
  1871.         After we use the DirItemize function, we test the returned value
  1872.         for a blank string.  If we have a blank string, then we know that
  1873.         the current directory has no subdirectories, and so we proceed to
  1874.         select the filename from the current directory (Goto getfile) .
  1875.         If, however, DirItemize returns a non-blank list, then we know
  1876.         that there is, in fact, at least one directory.  In that case, we
  1877.         use ItemSelect to bring up a list box.  Then, we test the value
  1878.         returned by ItemSelect.  If the returned value is a blank string,
  1879.         it means that the user did not select a directory from the list,
  1880.         and presumably wants a file in the current directory.  We happily
  1881.         oblige (Goto getfile).  On the other hand, a non-blank value
  1882.         returned from ItemSelect indicates that the user has selected a
  1883.         subdirectory from the list box.  In that case, we change to the
  1884.         selected directory, and loop back to the beginning of the
  1885.         directory selection routine (Goto getdir).  We continue this
  1886.         until either (a) the user selects a directory, or (b) there are
  1887.         no directories left to select.  Eventually, we get down to the
  1888.         file selection section of the batch file.
  1889.  
  1890.  
  1891.         Nicer Dialog Boxes
  1892.  
  1893.         Have you tried displaying long messages, and found that WinBatch
  1894.         didn't wrap the lines quite the way you wanted?  Here are a
  1895.         couple of tricks.
  1896.  
  1897.  
  1898.         Num2Char (integer)
  1899.  
  1900.         Converts a number to its character equivalent.
  1901.  
  1902.         We want to be able to insert carriage return/line feed
  1903.         combinations in our output, and the Num2Char function will let us
  1904.         do that.  A carriage return has an ASCII value of 13, and a line
  1905.         feed has an ASCII value of 10 (don't worry if you don't
  1906.         understand what that means).  To be able to use these values, we
  1907.         must convert them to characters, as follows:
  1908.  
  1909.           cr = num2char(13)
  1910.           lf = num2char(10)
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.         22
  1918.  
  1919.                                                                  TUTORIAL
  1920.  
  1921.  
  1922.  
  1923.         Now, we need to be able to place the variables 'cr' and 'lf' in
  1924.         our message.  For example, let's say we want to do this:
  1925.  
  1926.           Message("", "This is line one This is line two")
  1927.  
  1928.         If we just inserted the variables into the string, as in:
  1929.  
  1930.           Message("", "This is line one cr lf This is line two")
  1931.  
  1932.         we would not get the desired effect (try it and see).  WinBatch
  1933.         would  treat them as ordinary text.  However, WinBatch does
  1934.         provide us with a method of performing variable substitution such
  1935.         as this, and that is by enclosing the variables in percentage
  1936.         signs (%%).  If we do this:
  1937.  
  1938.           Message("", "This is line one %cr% %lf%This is line two")
  1939.  
  1940.         we get what we want.  Note that there is no space after '%lf%';
  1941.         this is so the second line will be aligned with the first line
  1942.         (every space inside the quote marks is significant).
  1943.         Now, wouldn't it be convenient if we could combine cr and lf into
  1944.         a single variable?  We can.
  1945.  
  1946.  
  1947.         StrCat (string[, string]...)
  1948.  
  1949.         Concatenates strings together.
  1950.  
  1951.         The StrCat function lets us combine any number of string
  1952.         constants and/or string variables.  Here's how we combine the
  1953.         variables 'cr' and 'lf' into the single variable 'crlf':
  1954.  
  1955.           crlf = StrCat(cr, lf)
  1956.  
  1957.         Note that the strings to be concatenated are separated by commas,
  1958.         within the parentheses.  Now, we can rewrite our example, as
  1959.         follows:
  1960.  
  1961.           cr = num2char(13)
  1962.           lf = num2char(10)
  1963.           crlf = StrCat(cr, lf)
  1964.           Message("", "This is line one %crlf%This is line two")
  1965.  
  1966.         If we wanted to re-use this message a number of times, it would
  1967.         be quite convenient to use the StrCat function to make a single
  1968.         variable out of it:
  1969.  
  1970.           cr = num2char(13)
  1971.           lf = num2char(10)
  1972.           crlf = StrCat(cr, lf)
  1973.           line1 = "This is line one"
  1974.           line2 = "This is line two"
  1975.           mytext = StrCat(line1, crlf, line2)
  1976.           Message("", mytext)
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.                                                                        23
  1983.  
  1984.         TUTORIAL
  1985.  
  1986.  
  1987.         Running DOS Programs
  1988.  
  1989.         WinBatch can run DOS programs, just like it runs Windows
  1990.         programs:
  1991.  
  1992.           dirchange("c:\game")
  1993.           run("scramble.exe", "")
  1994.  
  1995.         If you want to use an internal DOS command, such as DIR or TYPE,
  1996.         you can do so by running the DOS command interpreter,
  1997.         COMMAND.COM, with the '/c' program parameter, as follows:
  1998.  
  1999.           run("command.com", "/c type readme.txt")
  2000.  
  2001.         Everything that you would normally type on the DOS command line
  2002.         goes after the '/c' in the second parameter.  Here's another
  2003.         example:
  2004.  
  2005.           run("command.com", "/c type readme.txt | more")
  2006.  
  2007.         These examples assume that COMMAND.COM is in a directory on your
  2008.         DOS path.  If it isn't, you could specify a full path name for
  2009.         it:
  2010.  
  2011.           run("c:\command.com", "/c type readme.txt | more")
  2012.  
  2013.         Or, better still, you could use the WinBatch Environment
  2014.         function.
  2015.  
  2016.  
  2017.         Environment (env-variable)
  2018.  
  2019.         Gets a DOS environment variable.
  2020.         Since DOS always stores the full path and filename of the command
  2021.         processor in the environmental variable COMSPEC, it is an easy
  2022.         matter to retrieve this information:
  2023.  
  2024.           coms = environment("comspec")
  2025.  
  2026.         and use it in our batch file:
  2027.  
  2028.           coms = environment("comspec")
  2029.           run(coms, "/c type readme.txt")
  2030.  
  2031.         To get a DOS window, just run COMMAND.COM with no parameters:
  2032.  
  2033.           coms = environment("comspec")
  2034.           run(coms, "")
  2035.  
  2036.  
  2037.         Sending Keystrokes to Programs
  2038.  
  2039.         Here we come to one of the most useful and powerful features of
  2040.         WinBatch: the ability to send keystrokes to Windows programs,
  2041.         just as if you were typing them directly from the keyboard.
  2042.  
  2043.         SendKey (character-codes)
  2044.  
  2045.         Sends Keystrokes to the active application.
  2046.  
  2047.         24
  2048.  
  2049.                                                                  TUTORIAL
  2050.  
  2051.  
  2052.  
  2053.         This is an ideal way to automatically program the keys that you
  2054.         enter every time you start a certain program.  For example, to
  2055.         start up Notepad and have it prompt you for a file to open, you
  2056.         would use:
  2057.  
  2058.           Run("notepad.exe", "")
  2059.           SendKey("!FO")
  2060.  
  2061.         The parameter for SendKey is a string to send to the program.
  2062.         This string consists of standard characters, as well as some
  2063.         special characters which you will find listed under the entry for
  2064.         SendKey in the WBL Function Reference (pg. 78).  In the example
  2065.         above, the exclamation mark stands for the Alt key, so '!F' is
  2066.         the equivalent of pressing and holding down the Alt key while
  2067.         simultaneously pressing the 'F' key.  The 'O' in the example
  2068.         above is simply the letter 'O', and is the same as pressing the
  2069.         'O' key.  As you may know, 'Alt-F' brings up the 'File' menu in
  2070.         Notepad, and 'O' selects 'Open' from the 'File' menu.
  2071.         Here's another example:
  2072.  
  2073.           RunZoom("sol.exe", "")
  2074.           SendKey("!GC{RIGHT}{SP}~")
  2075.  
  2076.         This starts up Solitaire, brings up the 'Game' menu (!G), selects
  2077.         'Deck' (C), moves the cursor to the next card back style on the
  2078.         right ({RIGHT}), selects that card back ({SP}), and then selects
  2079.         'OK' (~).  And voila!  A different card design every time you
  2080.         play!
  2081.  
  2082.  
  2083.         Our Completed WinBatch File
  2084.  
  2085.         Here is the final version of the SOLITARE.WBT file that we've
  2086.         been building throughout this tutorial:
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.                                                                        25
  2113.  
  2114.         TUTORIAL
  2115.  
  2116.  
  2117.  
  2118.           ; solitare.wbt
  2119.           mins = AskLine("Solitaire", "How many minutes do you want to
  2120.             play?", "")
  2121.           If WinExist("Solitaire") == @TRUE Then Goto activate
  2122.           RunZoom("sol.exe", "")
  2123.           Goto loaded
  2124.           :activate
  2125.           WinActivate("Solitaire")
  2126.           WinZoom("Solitaire")
  2127.           :loaded
  2128.           SendKey("!GC{RIGHT}{SP}~")
  2129.           goal = mins * 60
  2130.           timer = 0
  2131.           :moretime
  2132.           remain = goal - timer
  2133.           WinTitle("Solitaire", "Solitaire (%remain% seconds left)")
  2134.           delay(10)
  2135.           timer = timer + 10
  2136.           If WinExist("Solitaire") == @FALSE Then Exit
  2137.           If timer < goal Then Goto moretime
  2138.           Beep
  2139.           WinClose("Solitaire")
  2140.           Message("Time's up", "Get back to work!")
  2141.  
  2142.         It  incorporates many of the concepts that we've discussed in
  2143.         this tutorial, as well as using some arithmetic (*, -, +) and
  2144.         relational (<) operators that are covered in the following
  2145.         section on the WinBatch language.
  2146.  
  2147.         If you can understand and follow the structures and processes
  2148.         illustrated in this sample file, and can incorporate them into
  2149.         your own WinBatch files, you are well on your way to becoming a
  2150.         WinBatch guru!
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.         26
  2177.  
  2178.                                                         WINBATCH LANGUAGE
  2179.  
  2180.  
  2181.  
  2182.  
  2183.                                 WINBATCH LANGUAGE
  2184.  
  2185.  
  2186.  
  2187.  
  2188.         Language Components
  2189.  
  2190.         The statements you write to execute the batch files are
  2191.         constructed from constants, variables, operators, functions,
  2192.         commands, and comments.
  2193.  
  2194.         Constants
  2195.  
  2196.         The programming language supports both integer and string
  2197.         constants.
  2198.  
  2199.         Integer Constants
  2200.  
  2201.         Integer constants are built from the digits 0 through 9.  They
  2202.         can range in magnitude from negative to positive 231 -1
  2203.         (approximately two billion).  Constants larger than these
  2204.         permissible magnitudes will produce unpredictable results.
  2205.  
  2206.         Examples of integer constants:
  2207.  
  2208.                    1
  2209.                  -45
  2210.               377849
  2211.          -1999999999
  2212.  
  2213.         String Constants
  2214.  
  2215.         String constants are comprised of displayable characters bounded
  2216.         by quote marks.  You can use double quotes ("), single quotes
  2217.         ('), or back quotes (`) to enclose a string constant, as long as
  2218.         the same type of quote is used to both start and end it.  If you
  2219.         need to embed the delimiting quote mark inside the string
  2220.         constant, use the delimiting quote mark twice.
  2221.         Examples of string constants:
  2222.  
  2223.           "a"
  2224.           `Betty Boop`
  2225.           "This constant has an embedded "" mark"
  2226.           'This constant also has an embedded " mark'
  2227.  
  2228.         Predefined Constants
  2229.  
  2230.         The programming language has a number of built-in integer
  2231.         constants that can be used for various purposes.  These start
  2232.         with the @-sign, and are case-insensitive (although we prefer to
  2233.         use ALL CAPS).
  2234.  
  2235.         Some predefined constants:
  2236.  
  2237.           @FALSE                            @TILE
  2238.           @NO                               @TRUE
  2239.           @STACK                            @YES
  2240.  
  2241.                                                                        27
  2242.  
  2243.         WINBATCH LANGUAGE
  2244.  
  2245.  
  2246.  
  2247.         A list of all the predefined constants can be found in Appendix
  2248.         A: Predefined Constants.
  2249.  
  2250.         Identifiers
  2251.  
  2252.         Identifiers are the names supplied for variables, functions, and
  2253.         commands in your program.
  2254.         An identifier is a sequence of one or more letters or digits that
  2255.         begins with a letter.  Identifiers may have up to 30 characters.
  2256.  
  2257.         All identifiers are case insensitive.  Upper- and lowercase char-
  2258.         acters may be mixed at will inside variable names, commands or
  2259.         functions.
  2260.  
  2261.         For example these statements all mean the same thing:
  2262.  
  2263.           AskLine(MyTitle, Prompt, Default)
  2264.           ASKLINE(MYTITLE, PROMPT, DEFAULT)
  2265.           aSkLiNe(MyTiTlE, pRoMpT, dEfAuLt)
  2266.  
  2267.         Variables
  2268.  
  2269.         A variable may contain an integer, a string, or a string
  2270.         representing an integer.  Automatic conversions between integers
  2271.         and strings are performed as a matter of course during execution.
  2272.  
  2273.         If a function requires a string parameter and an integer
  2274.         parameter is supplied, the variable will be automatically
  2275.         modified to include the representative string.
  2276.         If a function requires an integer parameter and a string
  2277.         parameter is supplied, an attempt will be made to convert the
  2278.         string to an integer.  If it does not convert successfully, an
  2279.         error will result.
  2280.  
  2281.         Keywords Are Reserved
  2282.  
  2283.         "Keywords" are the predefined identifiers that have special
  2284.         meaning to the programming language.  These cannot be used as
  2285.         variable names.
  2286.  
  2287.         WBL keywords consist of the functions, commands, and predefined
  2288.         constants.
  2289.  
  2290.         Some examples of reserved keywords:
  2291.  
  2292.           beep
  2293.           dirchange
  2294.           @Yes
  2295.           filecopy
  2296.  
  2297.         Operators
  2298.  
  2299.         The programming language operators take one operand ("unary
  2300.         operators") or two operands ("binary operators").
  2301.  
  2302.         Unary operators (integers only):
  2303.  
  2304.           -    Arithmetic Negation (Two's complement)
  2305.  
  2306.         28
  2307.  
  2308.                                                         WINBATCH LANGUAGE
  2309.  
  2310.  
  2311.  
  2312.           +    Identity (Unary plus)
  2313.           ~    Bitwise Not.  Changes each 0 bit to 1, and vice-versa.
  2314.           !    Logical Not.  Produces 0 (@FALSE) if the operand is
  2315.                nonzero, else 1 (@TRUE) if the operand is zero.
  2316.  
  2317.         Binary arithmetic operators (integers only):
  2318.  
  2319.           *    Multiplication
  2320.           /    Division
  2321.           mod  Modulo
  2322.           +    Addition
  2323.           -    Subtraction
  2324.           <<   Left Shift
  2325.           >>   Right Shift
  2326.           &    Bitwise And
  2327.           |    Bitwise Or
  2328.           ^    Bitwise Exclusive Or  (XOR)
  2329.           &&   Logical And
  2330.           | |     Logical Or
  2331.  
  2332.         Binary relational operators (integers and strings):
  2333.  
  2334.           >    Greater-than
  2335.           >=   Greater-than or equal
  2336.           <    Less-than
  2337.           <=   Less-than or equal
  2338.           ==   Equality
  2339.           != or <>Inequality
  2340.  
  2341.         Assignment operator (integers and strings):
  2342.  
  2343.           =    Assigns evaluated result of an expression to a variable
  2344.  
  2345.         Precedence and evaluation order
  2346.  
  2347.         The precedence of the operators affect the evaluation of operands
  2348.         in expressions.  Operands associated with higher-precedence
  2349.         operators are evaluated before the lower-precedence operators.
  2350.  
  2351.         The table below shows the precedence of the operators.  Where
  2352.         operators have the same precedence, they are evaluated from left
  2353.         to right.
  2354.  
  2355.         Operator            Description
  2356.  
  2357.           ( )               Parenthetical grouping
  2358.           ~ ! - +           Unary operators
  2359.           * / mod           Multiplication & Division
  2360.           + -               Addition & Subtraction
  2361.           <<  >>            Shift operators
  2362.           < <= == >= > != <>     Relational operators
  2363.           & ^ |             Bit manipulation operators
  2364.           && | |            Logical operators
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.                                                                        29
  2372.  
  2373.         WINBATCH LANGUAGE
  2374.  
  2375.  
  2376.         Comments
  2377.  
  2378.         A comment is a sequence of characters that are ignored when
  2379.         processing a command.  A semicolon (not otherwise part of a
  2380.         string constant) indicates the beginning of a comment.
  2381.  
  2382.         All characters to the right of the semicolon are considered
  2383.         comments and are ignored.
  2384.  
  2385.         Blank lines are also ignored.
  2386.  
  2387.         Examples of comments:
  2388.  
  2389.           ; This is a comment
  2390.           abc = 5 ;This is also a comment
  2391.  
  2392.         Statements
  2393.  
  2394.         Assignment Statements
  2395.  
  2396.         Assignment statements are used to set variables to specific or
  2397.         computed values.  Variables may be set to integers or strings.
  2398.         Examples:
  2399.  
  2400.           a = 5
  2401.           value = Average(a, 10, 15)
  2402.           location = "Northern Hemisphere"
  2403.           World = strcat(location, " ", "Southern Hemisphere")
  2404.  
  2405.         Control Statements
  2406.  
  2407.         Control statements are generally used to execute system
  2408.         management functions and consist of a call to a command without
  2409.         assigning any return values.
  2410.  
  2411.         Examples:
  2412.  
  2413.           run("clock.exe", "")
  2414.           delay(5)
  2415.           winclose("Clock")
  2416.           Exit
  2417.  
  2418.         Substitution
  2419.  
  2420.         The batch language has a powerful substitution feature which
  2421.         inserts the contents of a string variable into a statement before
  2422.         the line is parsed.
  2423.         To substitute the contents of a variable in the statement, simply
  2424.         put a percent-sign (%) on both sides of the variable name.
  2425.  
  2426.         Examples:
  2427.  
  2428.           MyCmd = "DirChange('C:\')"    ;set MyCmd to a command
  2429.           %MyCmd%                ;execute the command
  2430.  
  2431.         ...or consider this one:
  2432.  
  2433.           IniWrite("PC", "Owner", "Jenny")
  2434.           ...
  2435.           Owner = IniRead("PC", "Owner", "somebody")
  2436.           message("", "This is %Owner%'s PC")
  2437.         30
  2438.  
  2439.                                                         WINBATCH LANGUAGE
  2440.  
  2441.  
  2442.  
  2443.  
  2444.         will produce the output:
  2445.  
  2446.           This is Jenny's PC
  2447.  
  2448.         To put a single percent-sign (%) on a source line, specify a
  2449.         double percent sign(%%).  This is required even inside quoted
  2450.         strings.
  2451.  
  2452.         Function Parameters
  2453.  
  2454.         Most of the functions and commands in the language require
  2455.         parameters.  These come in three types:
  2456.  
  2457.           Integer
  2458.           String
  2459.           Variable name
  2460.  
  2461.         WinBatch performs automatic conversions between strings and
  2462.         integers, so in general you can use them interchangeably.
  2463.  
  2464.         Integer parameters may be any of the following:
  2465.  
  2466.           An integer (i.e. 23)
  2467.           A string representing an integer (i.e. "23")
  2468.           A variable containing an integer
  2469.           A variable containing a string representing an integer
  2470.  
  2471.         String parameters may be any of the following:
  2472.  
  2473.           A string
  2474.           An integer
  2475.           A variable containing a string
  2476.           A variable containing an integer
  2477.  
  2478.         Error Handling
  2479.  
  2480.         There are three types of errors that can occur while processing a
  2481.         batch file:  Minor, Moderate, and Fatal.  What happens when an
  2482.         error occurs depends on the current error mode, which is set with
  2483.         the ErrorMode function.
  2484.         There are three possible modes you can specify:
  2485.  
  2486.         @CANCEL
  2487.           User is notified when any error occurs, and then the batch
  2488.           file is canceled.  This is the default.
  2489.  
  2490.         @NOTIFY
  2491.           User is notified when any error occurs, and has option to
  2492.           continue unless the error is fatal.
  2493.  
  2494.         @OFF
  2495.           User is only notified if the error is moderate or fatal.  User
  2496.           has option to continue unless the error is fatal.
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.                                                                        31
  2503.  
  2504.         WINBATCH LANGUAGE
  2505.  
  2506.  
  2507.         The function LastError returns the code of the most-recent error
  2508.         encountered during the current batch file.
  2509.  
  2510.         Minor errors are numbered from 1000 to 1999.
  2511.         Moderate errors are numbered from 2000 to 2999.
  2512.         Fatal errors are numbered from 3000 to 3999.
  2513.  
  2514.         Error handling is reset to @CANCEL at the start of each batch
  2515.         file.
  2516.  
  2517.  
  2518.         The Functions & Statements
  2519.  
  2520.  
  2521.         Inputting Information
  2522.  
  2523.         AskLine (title, prompt, default)
  2524.           Lets user enter a line of information.
  2525.  
  2526.         AskYesNo (title, question)
  2527.           Lets user choose from Yes, No, or Cancel.
  2528.  
  2529.         ItemSelect (title, list, delimiter)
  2530.           Chooses an item from a listbox.
  2531.  
  2532.         TextBox (title, filename)
  2533.           Fills a listbox from text strings in a file.
  2534.  
  2535.  
  2536.         Displaying Information
  2537.  
  2538.         Beep
  2539.           Beeps at the user.
  2540.  
  2541.         Display (seconds, title, text)
  2542.           Momentarily displays a string.
  2543.  
  2544.         Message (title, text)
  2545.           Displays text in a message box.
  2546.  
  2547.         Pause (title, text)
  2548.           Displays text in a message box.
  2549.  
  2550.  
  2551.         File Management
  2552.  
  2553.         FileClose (filehandle)
  2554.           Closes a file.
  2555.  
  2556.         FileCopy (from-list, to-file, warning)
  2557.           Copies files.
  2558.  
  2559.         FileDelete (file-list)
  2560.           Deletes files.
  2561.  
  2562.         FileExist (filename)
  2563.           Determines if a file exists.
  2564.  
  2565.         32
  2566.  
  2567.                                                         WINBATCH LANGUAGE
  2568.  
  2569.         FileExtension (filename)
  2570.           Returns extension of file.
  2571.  
  2572.         FileItemize (file-list)
  2573.           Builds a list of files.
  2574.  
  2575.         FileLocate (filename)
  2576.           Finds a file within the current DOS path.
  2577.  
  2578.         FileMove (from-list, to-file, warning)
  2579.           Moves files to another set of pathnames.
  2580.  
  2581.         FileOpen (filename, open-type)
  2582.           Opens a STANDARD ASCII (only) file for reading or writing.
  2583.  
  2584.         FilePath (filename)
  2585.           Returns path of file.
  2586.  
  2587.         FileRead (filehandle)
  2588.           Reads data from a file.
  2589.  
  2590.         FileRename (from-list, to-file)
  2591.           Renames files to another set of names.
  2592.  
  2593.         FileRoot (filename)
  2594.           Returns root of file.
  2595.  
  2596.         FileSize (file-list)
  2597.           Adds up the total size of a set of files.
  2598.  
  2599.         FileWrite (filehandle,output-data)
  2600.           Writes data to a file.
  2601.  
  2602.  
  2603.         Directory Management
  2604.  
  2605.         DirChange ([d:]path)
  2606.           Changes the current directory.
  2607.  
  2608.         DirGet ( )
  2609.           Returns the current directory path.
  2610.  
  2611.         DirHome ( )
  2612.           Returns the initial directory path.
  2613.  
  2614.         DirItemize (dir-list)
  2615.           Builds a list of directories.
  2616.  
  2617.         DirMake ([d:]path)
  2618.           Creates a new directory.
  2619.  
  2620.         DirRemove ([d:]path)
  2621.           Removes an existing directory.
  2622.  
  2623.  
  2624.         Disk Drive Management
  2625.  
  2626.         DiskFree (drive-list)
  2627.           Returns the amount of free space on a set of drives.
  2628.  
  2629.         LogDisk (drive)
  2630.           Changes the logged disk drive.
  2631.                                                                        33
  2632.  
  2633.         WINBATCH LANGUAGE
  2634.  
  2635.         Window Management
  2636.  
  2637.         WinActivate (partial-windowname)
  2638.           Makes an application window the active window.
  2639.  
  2640.         WinArrange (style)
  2641.           Arranges all running application windows on the screen.
  2642.  
  2643.         WinClose (partial-windowname)
  2644.           Closes an application window.
  2645.  
  2646.         WinCloseNot (partial-windowname [, partial-windowname]...)
  2647.           Closes all application windows except those specified.
  2648.  
  2649.         WinConfig ( )
  2650.           Returns WIN3 mode flags.
  2651.  
  2652.         WinExist (partialwindowname)
  2653.           Tells if Window exists.
  2654.  
  2655.         WinGetActive ( )
  2656.           Gets the title of the active window.
  2657.  
  2658.         WinHide (partial-windowname)
  2659.           Hides an application window.
  2660.  
  2661.         WinIconize (partial-windowname)
  2662.           Turns an application window into an icon.
  2663.  
  2664.         WinItemize ( )
  2665.           Lists all the main windows currently running.
  2666.  
  2667.         WinPlace (x-ul, y-ul, x-br, y-br, partial-windowname)
  2668.           Changes the size and position of an application window on the
  2669.           screen.
  2670.  
  2671.         WinPosition (partialwindowname)
  2672.           Returns Window position.
  2673.  
  2674.         WinShow (partial-windowname)
  2675.           Shows a currently-hidden application window.
  2676.  
  2677.         WinTitle (partial-windowname, new-windowname)
  2678.           Changes the title of an application window.
  2679.  
  2680.         WinWaitClose (partial-windowname)
  2681.           Waits until an application window is closed.
  2682.  
  2683.         WinZoom (partial-windowname)
  2684.           Maximizes an application window to full-screen.
  2685.  
  2686.         Program Management
  2687.  
  2688.         Run (program-name, parameters)
  2689.           Runs a program as a normal window.
  2690.  
  2691.         RunHide (program-name, parameters)
  2692.           Runs a program in a hidden window.
  2693.  
  2694.         RunIcon (program-name, parameters)
  2695.           Runs a program as an icon.
  2696.         34
  2697.  
  2698.                                                         WINBATCH LANGUAGE
  2699.  
  2700.  
  2701.  
  2702.         RunZoom (program-name, parameters)
  2703.           Runs a program in a maximized window.
  2704.  
  2705.  
  2706.         String Handling
  2707.  
  2708.         Char2Num (string)
  2709.           Returns the ANSI code of a string's first character.
  2710.  
  2711.         IsNumber (string)
  2712.           Determines if a string represents a valid number.
  2713.  
  2714.         Num2Char (number)
  2715.           Converts a number to the ANSI character it represents.
  2716.  
  2717.         ParseData (string)
  2718.           Parses the passed string, just like passed parameters are
  2719.           parsed.
  2720.  
  2721.         StrCat (string[, string]...)
  2722.           Concatenates strings together.
  2723.  
  2724.         StrCmp (string1, string2)
  2725.           Compares two strings.
  2726.  
  2727.         StrFill (string, string-length)
  2728.           Builds a string from a repeated smaller string.
  2729.  
  2730.         StrFix (base-string, padding-string, length)
  2731.           Pads or truncates a string to a fixed length.
  2732.  
  2733.         StrICmp (string1, string2)
  2734.           Compares two strings, ignoring their case.
  2735.  
  2736.         StrIndex (main-str, sub-str, start, direction)
  2737.           Locates a string within a larger string.
  2738.  
  2739.         StrLen (string)
  2740.           Returns the length of a string
  2741.         StrLower (string)
  2742.           Converts a string to all lower-case characters.
  2743.  
  2744.         StrReplace (string,old,new)
  2745.           Replaces all occurrences of a substring with another.
  2746.  
  2747.         StrScan (main-str, delims, start, direction)
  2748.           Finds an occurrence of one or more delimiter characters in a
  2749.           string.
  2750.  
  2751.         StrSub (string, start, length)
  2752.           Returns a substring from within a string.
  2753.  
  2754.         StrTrim (string)
  2755.           Trims leading and trailing blanks from a string.
  2756.  
  2757.         StrUpper (string)
  2758.           Converts a string to all upper-case characters.
  2759.  
  2760.  
  2761.                                                                        35
  2762.  
  2763.         WINBATCH LANGUAGE
  2764.  
  2765.  
  2766.         Arithmetic Functions
  2767.  
  2768.         Abs (number)
  2769.           Returns the absolute value of a number.
  2770.  
  2771.         Average (num [, num]...)
  2772.           Returns the average of a list of integers.
  2773.  
  2774.         Max (num [, num]...)
  2775.           Determines the highest number in a list.
  2776.  
  2777.         Min (num [, num]...)
  2778.           Determines the lowest number in a list.
  2779.  
  2780.         Random (max)
  2781.           Generates a positive random number.
  2782.  
  2783.  
  2784.         Clipboard Handling
  2785.  
  2786.         ClipAppend (string)
  2787.           Appends a string to the end of the Clipboard.
  2788.  
  2789.         ClipGet ( )
  2790.           Returns the Clipboard contents into a string.
  2791.  
  2792.         ClipPut (string)
  2793.           Replaces the Clipboard contents with a string.
  2794.  
  2795.  
  2796.         System Control
  2797.  
  2798.         Call (filename.wbt, parameters)
  2799.           Calls another WBT file as a subroutine.
  2800.  
  2801.         CallExt (filename.wbt, parameters)
  2802.           Calls another WBT file as a separate subprogram.
  2803.  
  2804.         DateTime ( )
  2805.           Returns the current date and time.
  2806.  
  2807.         Debug (mode)
  2808.           Turns Debug mode on or off.
  2809.  
  2810.         Delay (seconds)
  2811.           Pauses batch file execution.
  2812.  
  2813.         DOSVersion (level)
  2814.           Returns the version numbers of the current version of DOS.
  2815.  
  2816.         Drop (var [, var]...)
  2817.           Deletes variables to recover their memory.
  2818.  
  2819.         EndSession ( )
  2820.           Ends the current Windows session.
  2821.  
  2822.         Environment (env-variable)
  2823.           Returns the value of a DOS environment variable.
  2824.  
  2825.         ErrorMode (mode)
  2826.           Sets what happens in the event of an error.
  2827.         36
  2828.  
  2829.                                                         WINBATCH LANGUAGE
  2830.  
  2831.         Exclusive (mode)
  2832.           Controls whether or not other Windows program will get any
  2833.           time to execute.
  2834.  
  2835.         Execute statement
  2836.           Directly executes a WinBatch statement.
  2837.  
  2838.         Exit
  2839.           Exits the current batch file's operation.
  2840.  
  2841.         Goto label
  2842.           Changes the flow of control in a batch file.
  2843.  
  2844.         If ... Then
  2845.           Conditionally performs a function.
  2846.  
  2847.         IgnoreInput (mode)
  2848.           Turns off hardware input to windows.
  2849.  
  2850.         IniRead (section, keyname, default)
  2851.           Reads a string from the win.ini file.
  2852.  
  2853.         IniReadPvt (section, keyname, default, filename)
  2854.           For reading private ini files.
  2855.  
  2856.         IniWrite (section, keyname, string)
  2857.           Writes a string to the win.ini file.
  2858.  
  2859.         IniWritePvt (section, keyname, data, filename)
  2860.           For writing private ini files.
  2861.  
  2862.         IsDefined (variable)
  2863.           Determines if a variable is currently defined.
  2864.  
  2865.         IsKeyDown (key-codes)
  2866.           Tells about keys/mouse.
  2867.  
  2868.         IsLicensed ( )
  2869.           Tells if WinBatch is licensed.
  2870.  
  2871.         LastError ( )
  2872.           Returns the last error encountered.
  2873.  
  2874.         Return ( )
  2875.           Used to return from a Call or a CallExt to the calling
  2876.           program.
  2877.  
  2878.         SendKey (character-codes)
  2879.           Sends Keystrokes to the active application.
  2880.  
  2881.         SKDebug (mode)
  2882.           Controls how SendKey works
  2883.  
  2884.         Version ( )
  2885.           Returns the version of WinBatch currently running.
  2886.  
  2887.         WinVersion (level)
  2888.           Gets the version of Windows that is currently running.
  2889.  
  2890.         Yield
  2891.           Pauses batch file processing so other applications can process
  2892.           some messages.
  2893.                                                                        37
  2894.  
  2895.                                                    WBL FUNCTION REFERENCE
  2896.  
  2897.  
  2898.  
  2899.  
  2900.                              WBL FUNCTION REFERENCE
  2901.  
  2902.  
  2903.  
  2904.  
  2905.         Introduction
  2906.  
  2907.         WinBatch gives you almost a hundred functions and control
  2908.         statements, which we describe in detail in this section.
  2909.         We use a shorthand notation to indicate the syntax of the
  2910.         functions.
  2911.  
  2912.         Function names and other actual characters you type are in
  2913.         boldface.  Optional parameters are enclosed in square brackets "[
  2914.         ]".  When a function takes a variable number of parameters, the
  2915.         variable parts will be followed by ellipses ("...").
  2916.  
  2917.         Take for example string concatenation:
  2918.  
  2919.         StrCat (string[, string]...)
  2920.  
  2921.         This says that the StrCat function takes at least one string
  2922.         parameter.  Optionally you can specify more strings to
  2923.         concatenate.  If you do, you must separate the strings with
  2924.         commas.
  2925.  
  2926.         For each function and control statement, we show you the Syntax,
  2927.         describe the Parameters (if any), the value it Returns (if any),
  2928.         a description of the function, any nonfatal Errors specific to
  2929.         the function, Example code (shown in courier type), and related
  2930.         functions you may want to See Also.
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.                                                                        39
  2958.  
  2959.         WBL FUNCTION REFERENCE
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.         Abs
  2967.  
  2968.         Returns the magnitude of the argument.
  2969.  
  2970.         Syntax:
  2971.           Abs (integer)
  2972.  
  2973.         Parameters:
  2974.           integer = integer whose absolute value is desired.
  2975.  
  2976.         Returns:
  2977.           (integer) absolute value of argument.
  2978.  
  2979.         Example:
  2980.           DY = abs(y1 - y2)
  2981.           Message("Years", "There are %DY% years 'twixt %y1% and %y2%")
  2982.  
  2983.         See Also:
  2984.           Average, Max, Min
  2985.  
  2986.  
  2987.  
  2988.         AskLine
  2989.  
  2990.         Prompts the user for one line of input.
  2991.  
  2992.         Syntax:
  2993.           AskLine (title, prompt, default)
  2994.  
  2995.         Parameters:
  2996.           "title" = title of the dialog box.
  2997.           "prompt" =   question to be put to the user.
  2998.           "default" =  default answer.
  2999.  
  3000.         Returns:
  3001.           (string)  user response.
  3002.  
  3003.         Use this command to query the user for a line of data.  The
  3004.         entire user response will be returned if the user presses the OK
  3005.         button or the Enter key.  If they press Cancel, the batch file
  3006.         processing is canceled.
  3007.  
  3008.         Example:
  3009.           Name = AskLine("Dessert", "Please enter your name", "")
  3010.           Dsrt = AskLine("Dessert", "Favorite dessert?", "Ice Cream")
  3011.           message(strcat(Name,"'s dessert is "), Dsrt)
  3012.  
  3013.         See Also:
  3014.           AskYesNo, Display, ItemSelect, Message, Pause, TextBox
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.         40
  3024.  
  3025.                                                    WBL FUNCTION REFERENCE
  3026.  
  3027.  
  3028.  
  3029.         AskYesNo
  3030.  
  3031.         Prompts the user for a YES or NO answer.
  3032.  
  3033.         Syntax:
  3034.           AskYesNo (title, question)
  3035.  
  3036.         Parameters
  3037.           "title" = title of the question box.
  3038.           "question" = question to be put to the user.
  3039.  
  3040.         Returns:
  3041.           (integer) @YES or @NO, depending on the button pressed.
  3042.  
  3043.         This command displays a message box with three pushbuttons - Yes,
  3044.         No, and Cancel.  If the user presses Cancel, the current batch
  3045.         file is ended so there is no return value.
  3046.  
  3047.         Example:
  3048.           q = AskYesNo('Testing', 'Please press "YES"')
  3049.           If q == @YES Then Exit
  3050.           Display(3, 'ERROR', 'I said press "YES"')
  3051.  
  3052.         See Also:
  3053.           AskLine, Display, ItemSelect, Message, Pause, TextBox
  3054.  
  3055.  
  3056.  
  3057.         Average
  3058.  
  3059.         Provides the integer average of the arguments.
  3060.  
  3061.         Syntax:
  3062.           Average (integer [, integer]...)
  3063.  
  3064.         Parameters:
  3065.           integer = integers to get the average of.
  3066.  
  3067.         Returns:
  3068.           (integer) average of the arguments.
  3069.  
  3070.         Use this command to compute the average of a series of numbers.
  3071.         This function returns an integer value, so there can be some
  3072.         rounding error involved.
  3073.  
  3074.         Errors:
  3075.           2060 "Average function syntax error"
  3076.  
  3077.         Example:
  3078.           Ave = Average(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
  3079.           Message("The average is", Ave)
  3080.  
  3081.         See Also:
  3082.           Abs, Max, Min
  3083.  
  3084.  
  3085.  
  3086.  
  3087.                                                                        41
  3088.  
  3089.         WBL FUNCTION REFERENCE
  3090.  
  3091.  
  3092.  
  3093.         Beep
  3094.  
  3095.         Beeps once.
  3096.  
  3097.         Syntax:
  3098.           Beep
  3099.  
  3100.         Use this command to produce a short beep, generally to alert the
  3101.         user to an error situation.
  3102.  
  3103.         Example:
  3104.           Beep
  3105.           Pause("WARNING!!!", "You are about to destroy data!")
  3106.  
  3107.  
  3108.  
  3109.         Call
  3110.  
  3111.         Calls another WBT file as a subroutine.
  3112.  
  3113.         Syntax:
  3114.           Call (filename.wbt, parameters)
  3115.  
  3116.         Parameters:
  3117.           "filename.wbt" =  the WBT file you are calling.  The extension
  3118.                     is required.
  3119.           "parameters" = the parameters to pass to the file, if any, in
  3120.                     the form "p1 p2 p3  ... pn".
  3121.  
  3122.         Returns:
  3123.           (integer) always @FALSE.
  3124.  
  3125.         Can pass parameters.  All variables are common (global) between
  3126.         the calling and the callee WBT file.
  3127.  
  3128.         Example:
  3129.           Call("chk-nam.wbt", "Susie")
  3130.  
  3131.         See Also:
  3132.           CallExt
  3133.  
  3134.  
  3135.  
  3136.         CallExt
  3137.  
  3138.         Calls another WBT file as a separate subprogram.
  3139.  
  3140.         Syntax:
  3141.           Callext (filename.wbt, parameters)
  3142.  
  3143.         Parameters:
  3144.           "filename.wbt" =  the WBT file you are calling.  The extension
  3145.                     is required.
  3146.           "parameters" = the parameters to pass to the file, if any, in
  3147.                     the form "p1 p2 p3  ... pn".
  3148.  
  3149.  
  3150.  
  3151.  
  3152.         42
  3153.  
  3154.                                                    WBL FUNCTION REFERENCE
  3155.  
  3156.  
  3157.  
  3158.         Returns:
  3159.           (integer) always @FALSE.
  3160.  
  3161.         Can pass parameters to the file.  No return value possible.  All
  3162.         variables are different.
  3163.  
  3164.         Example:
  3165.           CallExt("Chk-Num.wbt", "987 234 929")
  3166.  
  3167.         See Also:
  3168.           Call
  3169.  
  3170.  
  3171.  
  3172.         Char2Num
  3173.  
  3174.         Converts the first character of a string to its numeric
  3175.         equivalent.
  3176.  
  3177.         Syntax:
  3178.           Char2Num (string)
  3179.  
  3180.         Parameters:
  3181.           "string" =   any text string.  Only the first character will be
  3182.                     converted.
  3183.  
  3184.         Returns:
  3185.           (integer) ANSI character code.
  3186.  
  3187.         This function returns the 8-bit ANSI code corresponding to the
  3188.         first character of the string parameter.
  3189.  
  3190.         Note:  For the commonly-used characters (with codes below 128),
  3191.         ANSI and ASCII characters are identical.
  3192.  
  3193.         Example:
  3194.           ; Show the hex equivalent of entered character
  3195.           InpChar = AskLine("ANSI Equivalents", "Char:", "")
  3196.           Ansi = strsub(InpChar, 1, 1)
  3197.           AnsiEquiv = Char2Num(InpChar)
  3198.           Message("ANSI Codes", "%Ansi% => %AnsiEquiv%")
  3199.  
  3200.         See Also:
  3201.           Num2Char
  3202.  
  3203.  
  3204.  
  3205.         ClipAppend
  3206.  
  3207.         Appends a string to the Clipboard.
  3208.  
  3209.         Syntax:
  3210.           ClipAppend (string)
  3211.  
  3212.         Parameters:
  3213.           "string" =   text string to add to Clipboard.
  3214.  
  3215.  
  3216.  
  3217.  
  3218.                                                                        43
  3219.  
  3220.         WBL FUNCTION REFERENCE
  3221.  
  3222.  
  3223.  
  3224.         Returns:
  3225.           (integer) @TRUE if string was appended;
  3226.                     @FALSE if Clipboard ran out of memory.
  3227.  
  3228.         Use this command to append a string to the Windows Clipboard.
  3229.         The Clipboard must either contain text data or be empty for this
  3230.         command to succeed.
  3231.  
  3232.         Example:
  3233.           ; The code below will append 2 copies of the
  3234.           ; Clipboard contents back to the Clipboard, resulting
  3235.           ; in 3 copies of the original contents with a CR/LF
  3236.           ; between each copy.
  3237.           a = clipget()
  3238.           crlf = strcat(num2char(13), num2char(10))
  3239.           clipappend(crlf)
  3240.           clipappend(a)
  3241.           clipappend(crlf)
  3242.           clipappend(a)
  3243.  
  3244.         See Also:
  3245.           ClipGet, ClipPut
  3246.  
  3247.  
  3248.  
  3249.         ClipGet
  3250.  
  3251.         Returns the contents of the Clipboard.
  3252.  
  3253.         Syntax:
  3254.           ClipGet ( )
  3255.  
  3256.         Returns:
  3257.           (string)  clipboard contents.
  3258.  
  3259.         Use this command to copy text from the Windows Clipboard into a
  3260.         string variable.
  3261.  
  3262.         Note:  If the Clipboard contains an excessively large string a
  3263.         (fatal) out of memory error may occur.
  3264.  
  3265.         Example:
  3266.           ; The code below will convert Clipboard contents to
  3267.           ; uppercase
  3268.           clipput(strupper(clipget()))
  3269.           a = clipget()
  3270.           message("UPPERCASE Clipboard Contents", a)
  3271.  
  3272.         See Also:
  3273.           ClipAppend, ClipPut
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.         44
  3284.  
  3285.                                                    WBL FUNCTION REFERENCE
  3286.  
  3287.  
  3288.  
  3289.         ClipPut
  3290.  
  3291.         Copies a string to the clipboard.
  3292.  
  3293.         Syntax:
  3294.           ClipPut (string)
  3295.  
  3296.         Parameters:
  3297.           "string" =   any text string.
  3298.  
  3299.         Returns:
  3300.           (integer) @TRUE if string was copied;
  3301.                     @FALSE if clipboard ran out of memory.
  3302.  
  3303.         Use this command to copy a string to the Windows Clipboard.  The
  3304.         previous Clipboard contents will be lost.
  3305.  
  3306.         Example:
  3307.           ; The code below will convert Clipboard contents to
  3308.           ; lowercase
  3309.           clipput(strlower(clipget()))
  3310.           a = clipget ()
  3311.           message("lowercase Clipboard Contents", a)
  3312.  
  3313.         See Also:
  3314.           ClipAppend, ClipGet
  3315.  
  3316.  
  3317.  
  3318.         DateTime
  3319.  
  3320.         Provides the current Date and time.
  3321.  
  3322.         Syntax:
  3323.           DateTime ( )
  3324.  
  3325.         Returns:
  3326.           (string)  Today's Date and time
  3327.  
  3328.         This function will return the current date and time in a pre-
  3329.         formatted string.  The format it is returned in depends on how it
  3330.         is set up in the international section of the WIN.INI file:
  3331.         ddd mm:dd:yy hh:mm:ss XX
  3332.         ddd dd:mm:yy hh:mm:ss XX
  3333.         ddd yy:mm:dd hh:mm:ss XX
  3334.  
  3335.         Where
  3336.           ddd is day of the week (e.g. Mon)
  3337.           mm  is the month (e.g. 10)
  3338.           dd  is the day of the month (e.g. 23)
  3339.           yy  is the year (e.g. 90)
  3340.           hh  is the hours
  3341.           mm  is the minutes
  3342.           ss  is the seconds
  3343.           XX  is the Day/Night code (e.g. AM or PM)
  3344.  
  3345.         Note:  Windows provides even more formatting options than this.
  3346.  
  3347.  
  3348.                                                                        45
  3349.  
  3350.         WBL FUNCTION REFERENCE
  3351.  
  3352.  
  3353.  
  3354.         The WIN.INI file will be examined to determine which format to
  3355.         use.  You can adjust the WIN.INI file via the International
  3356.         section of the Control Panel if the format isn't what you prefer.
  3357.  
  3358.         Example:
  3359.           ; assuming the current standard is U.S.
  3360.           ; (i.e. day  dd/mm/yy hh:mm:ss AM):
  3361.           Message("Current Date & Time", DateTime())
  3362.  
  3363.  
  3364.  
  3365.         Debug
  3366.  
  3367.         Controls the debug mode.
  3368.  
  3369.         Syntax:
  3370.           Debug (mode)
  3371.  
  3372.         Parameters:
  3373.           mode =    @ON or @OFF
  3374.  
  3375.         Returns:
  3376.           (integer) Previous Debug mode
  3377.  
  3378.         Use this command to turn the debug mode on or off.  The default
  3379.         is @OFF.
  3380.  
  3381.         When Debug mode is on, WinBatch will display the command just
  3382.         executed, its result (if any), any error conditions, and the next
  3383.         command to execute.
  3384.  
  3385.         The commands are displayed in a special dialog box.  As you can
  3386.         see in the Example section following, the dialog box gives the
  3387.         user four options:  Next, Run, Cancel and Show Var.
  3388.         Next executes the next statement and remains in debug mode.
  3389.  
  3390.         Run exits debug mode and runs the rest of the program normally.
  3391.         Cancel terminates the current batch file.
  3392.  
  3393.         Show Var displays the contents of a variable whose name the user
  3394.         entered in the edit box.
  3395.  
  3396.         Example:
  3397.           ; Debug example
  3398.           Debug(@ON)
  3399.           a = 6
  3400.           q = AskYesNo("Testing Debug Mode", "Is the Pope Catholic")
  3401.           Debug(@OFF)
  3402.           b = a + 4
  3403.  
  3404.         See Also:
  3405.           ErrorMode, LastError
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.         46
  3414.  
  3415.                                                    WBL FUNCTION REFERENCE
  3416.  
  3417.  
  3418.  
  3419.         Delay
  3420.  
  3421.         Pauses execution a specified amount of time.
  3422.  
  3423.         Syntax:
  3424.           Delay (seconds)
  3425.  
  3426.         Parameters:
  3427.           seconds = number of seconds to delay (2 - 15)
  3428.  
  3429.         Returns:
  3430.           (integer) always @TRUE
  3431.  
  3432.         Seconds must be between 2 and 15. Smaller or larger numbers will
  3433.         be adjusted accordingly.
  3434.  
  3435.         Example:
  3436.           Message("Wait", "About 15 seconds")
  3437.           Delay(15)
  3438.           Message("Hi", "I'm Baaaaaaack")
  3439.  
  3440.         See Also:
  3441.           Yield
  3442.  
  3443.  
  3444.  
  3445.  
  3446.  
  3447.  
  3448.         DirChange
  3449.  
  3450.         Changes the current directory.  Can also log a new drive.
  3451.  
  3452.         Syntax:
  3453.           DirChange ([d:]path)
  3454.  
  3455.         Parameters:
  3456.           "[d:]" =  an optional disk drive to log onto.
  3457.           "path" =  the desired path.
  3458.  
  3459.         Returns:
  3460.           (integer) @TRUE if directory was changed;
  3461.                     @FALSE if the path could not be found.
  3462.  
  3463.         Use this command to change the current working directory to
  3464.         another directory, either on the same or a different disk drive.
  3465.  
  3466.  
  3467.  
  3468.                                                                        47
  3469.  
  3470.         WBL FUNCTION REFERENCE
  3471.  
  3472.  
  3473.  
  3474.         Errors:
  3475.           1031 "DirChange: Dir not found/changed"
  3476.  
  3477.         Example:
  3478.           DirChange("c:\")
  3479.           textbox("This is your CONFIG.SYS file", "config.sys")
  3480.  
  3481.         See Also:
  3482.           DirGet, DirHome, LogDisk
  3483.  
  3484.  
  3485.  
  3486.         DirGet
  3487.  
  3488.         Gets the Current Working Directory.
  3489.  
  3490.         Syntax:
  3491.           DirGet ( )
  3492.  
  3493.         Returns:
  3494.           (string) =   Current Working Directory.
  3495.  
  3496.         Use this command to determine which directory we are currently
  3497.         in.  It's especially useful when changing drives or directories
  3498.         temporarily.
  3499.  
  3500.         Example:
  3501.           ; Get, then restore current working directory
  3502.           OrigDir = DirGet()
  3503.           DirChange("c:\")
  3504.           FileCopy("config.sys", "%OrigDir%xxxtemp.xyz", @FALSE)
  3505.           DirChange(OrigDir)
  3506.  
  3507.         See Also:
  3508.           DirHome
  3509.  
  3510.  
  3511.  
  3512.         DirHome
  3513.  
  3514.         Returns directory containing the WinBatch executable files.
  3515.  
  3516.         Syntax:
  3517.           DirHome ( )
  3518.  
  3519.         Returns:
  3520.           (string)  pathname of the home directory.
  3521.  
  3522.         Use this command to determine the location of WINBATCH.EXE.
  3523.  
  3524.         Example:
  3525.           a = DirHome()
  3526.           Message("WinBatch Executable is in ", a)
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.         48
  3535.  
  3536.                                                    WBL FUNCTION REFERENCE
  3537.  
  3538.  
  3539.  
  3540.         See Also:
  3541.           DirGet
  3542.  
  3543.  
  3544.  
  3545.         DirItemize
  3546.  
  3547.         Returns a space-delimited list of directories.
  3548.  
  3549.         Syntax:
  3550.           DirItemize (dir-list)
  3551.  
  3552.         Parameters:
  3553.           "dir-list" = a string containing a set of subdirectory names,
  3554.                     which may be wildcarded.
  3555.         Returns:
  3556.           (string)  list of directories.
  3557.  
  3558.         This function compiles a list of subdirectories and separates the
  3559.         names with spaces.
  3560.  
  3561.         This is especially useful in conjunction with the ItemSelect
  3562.         function, which enables the user to choose an item from such a
  3563.         space-delimited list.
  3564.         DirItemize("*.*") returns all dirs
  3565.  
  3566.         Example:
  3567.           ;Verify directory selection:
  3568.           a = DirItemize("")
  3569.           ItemSelect("Directories", a, " ")
  3570.  
  3571.         See Also:
  3572.           FileItemize, WinItemize, ItemSelect
  3573.  
  3574.  
  3575.  
  3576.         DirMake
  3577.  
  3578.         Creates a new directory.
  3579.  
  3580.         Syntax:
  3581.           DirMake ([d:]path)
  3582.  
  3583.         Parameters:
  3584.           "[d:]" =  the desired disk drive.
  3585.           "path" =  the path to create.
  3586.  
  3587.         Returns:
  3588.           (integer) @TRUE if the directory was successfully created;
  3589.                     @FALSE if it wasn't.
  3590.  
  3591.         Use this command to create a new directory.
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.                                                                        49
  3601.  
  3602.         WBL FUNCTION REFERENCE
  3603.  
  3604.  
  3605.  
  3606.         Errors:
  3607.           1029 "DirMake: Dir not created"
  3608.  
  3609.         Example:
  3610.           DirMake("c:\XXXSTUFF")
  3611.  
  3612.         See Also:
  3613.           DirRemove
  3614.  
  3615.  
  3616.  
  3617.         DirRemove
  3618.  
  3619.         Removes a directory.
  3620.  
  3621.         Syntax:
  3622.           DirRemove (dir-list)
  3623.  
  3624.         Parameters:
  3625.           "dir-list" = a space-delimited list of directory pathnames.
  3626.  
  3627.         Returns:
  3628.           (integer) @TRUE if the directory was successfully removed;
  3629.                     @FALSE if it wasn't.
  3630.  
  3631.         Use this command to delete directories.  You can delete one or
  3632.         more at a time by separating directory names with spaces.  You
  3633.         cannot, however, use wildcards.
  3634.  
  3635.         Errors:
  3636.           1030 "DirRemove: Dir not removed"
  3637.  
  3638.         Examples:
  3639.           DirRemove("c:\XXXSTUFF")
  3640.           DirRemove("tempdir1 tempdir2 tempdir3")
  3641.  
  3642.         See Also:
  3643.           DirMake
  3644.  
  3645.  
  3646.  
  3647.         DiskFree
  3648.  
  3649.         Finds the total space available on a group of drives.
  3650.  
  3651.         Syntax:
  3652.           DiskFree (drive-list)
  3653.  
  3654.         Parameters:
  3655.           "drive-list" = at least one drive letter, separated by spaces.
  3656.  
  3657.         Returns:
  3658.           (integer) the number of bytes available on all the specified
  3659.                     drives.
  3660.  
  3661.         This function takes a string consisting of drive letters,
  3662.         separated by spaces.  Only the first character of each non-blank
  3663.  
  3664.  
  3665.         50
  3666.  
  3667.                                                    WBL FUNCTION REFERENCE
  3668.  
  3669.  
  3670.  
  3671.         group of characters is used to determine the drives, so you can
  3672.         use just the drive letters, or add a colon (":"), or add a
  3673.         backslash ("\"), or even a whole pathname and still get a
  3674.         perfectly valid result.
  3675.  
  3676.         Example:
  3677.           Size = DiskFree("c d")
  3678.           Message("Space Available on C: & D:", Size)
  3679.  
  3680.         See Also:
  3681.           FileSize
  3682.  
  3683.  
  3684.  
  3685.         Display
  3686.  
  3687.         Displays a message to the user for a specified time.
  3688.  
  3689.         Syntax:
  3690.           Display (seconds, title, text)
  3691.  
  3692.         Parameters:
  3693.           seconds = integer seconds to display the message (1-15).
  3694.           "title" = Title of the window to be displayed.
  3695.           "text" =  Text of the window to be displayed.
  3696.  
  3697.         Returns:
  3698.           (integer) always @TRUE.
  3699.  
  3700.         Seconds must be between 1 and 15.  Smaller or larger numbers will
  3701.         be adjusted accordingly.
  3702.         Use this command to display a message for a few seconds, and then
  3703.         continue with processing without user input.
  3704.  
  3705.         The display box may be prematurely canceled by the user by
  3706.         clicking it with a mouse, or hitting any character.
  3707.  
  3708.         Example:
  3709.           name = askline("Desserts", "Please enter your name", "")
  3710.           dsrt = askline("Desserts", "Favorite dessert?", "Ice Cream")
  3711.           display(3, "%name%'s Dessert", dsrt)
  3712.  
  3713.         See Also:
  3714.           Pause, Message
  3715.  
  3716.  
  3717.  
  3718.         DOSVersion
  3719.  
  3720.         Returns the version numbers of the current version of DOS.
  3721.  
  3722.         Syntax:
  3723.           DOSVersion (level)
  3724.  
  3725.         Parameters:
  3726.           level =   @MAJOR or @MINOR.
  3727.  
  3728.  
  3729.  
  3730.  
  3731.                                                                        51
  3732.  
  3733.         WBL FUNCTION REFERENCE
  3734.  
  3735.  
  3736.  
  3737.  
  3738.         @MAJOR returns the integer part (to the left of the decimal).
  3739.         @MINOR returns the decimal part (to the right of the decimal).
  3740.  
  3741.         Example:
  3742.           r = DOSVersion(@MAJOR)
  3743.           v = DOSVersion(@MINOR)
  3744.           Message("DOS Version", "%r%.%v%")
  3745.  
  3746.  
  3747.  
  3748.         Drop
  3749.  
  3750.         Removes variables from memory.
  3751.  
  3752.         Syntax:
  3753.           Drop (var, [var]...)
  3754.  
  3755.         Parameters:
  3756.           var =     variable names to remove.
  3757.  
  3758.         Returns:
  3759.           (integer) @TRUE.
  3760.  
  3761.         This function removes variables from the language processor's
  3762.         variable list, and recovers the memory associated with the
  3763.         variable (and possibly related string storage).
  3764.  
  3765.         Example:
  3766.           A = "A variable"
  3767.           B = "Another one"
  3768.           Drop(A, B)   ; This removes A and B from memory
  3769.  
  3770.  
  3771.  
  3772.         EndSession
  3773.  
  3774.         Ends the Windows session.
  3775.  
  3776.         Syntax:
  3777.           EndSession ( )
  3778.  
  3779.         Use this command to end the Windows session.  This command is
  3780.         equivalent to closing the Program Manager window.
  3781.  
  3782.         Example:
  3783.           Sure = AskYesNo ("End Session", "You SURE you want to exit
  3784.             Windows?")
  3785.           If Sure == @No Then Goto Cancel
  3786.           EndSession()
  3787.           :Cancel
  3788.           Message("", "Exit Windows canceled")
  3789.  
  3790.         See Also:
  3791.           Exit, WinClose, WinCloseNot
  3792.  
  3793.  
  3794.  
  3795.  
  3796.         52
  3797.  
  3798.                                                    WBL FUNCTION REFERENCE
  3799.  
  3800.  
  3801.  
  3802.         Environment
  3803.  
  3804.         Gets a DOS environment variable.
  3805.  
  3806.         Syntax:
  3807.           Environment (env-variable)
  3808.  
  3809.         Parameters:
  3810.           "env-variable" =  any defined environment variable.
  3811.  
  3812.         Returns:
  3813.           (string)  environment variable contents.
  3814.  
  3815.         Use this command to query the DOS environment.
  3816.  
  3817.         Example:
  3818.           ; Display the PATH for this DOS session
  3819.           CurrPath = Environment("PATH")
  3820.           Message("Current DOS Path", CurrPath)
  3821.  
  3822.         See Also:
  3823.           IniRead, Version, WinVersion
  3824.  
  3825.  
  3826.  
  3827.         ErrorMode
  3828.  
  3829.         Specifies how to handle errors.
  3830.  
  3831.         Syntax:
  3832.           ErrorMode (mode)
  3833.  
  3834.         Parameters:
  3835.           mode =    @CANCEL or @NOTIFY or @OFF.
  3836.  
  3837.         Returns:
  3838.           (integer) previous error setting.
  3839.  
  3840.         Use this command to control the effects of runtime errors.  The
  3841.         default is @CANCEL, meaning the execution of the batch file will
  3842.         be canceled for any error.
  3843.  
  3844.         @CANCEL:  All runtime errors will cause execution to be
  3845.         canceled.  The user will be notified which error occurred.
  3846.  
  3847.         @NOTIFY:  All runtime errors will be reported to the user, and
  3848.         they can choose to continue if it isn't fatal.
  3849.  
  3850.         @OFF:  Minor runtime errors will be suppressed. Moderate and
  3851.         fatal errors will be reported to the user.  User has the option
  3852.         of continuing if the error is not fatal.
  3853.         In general we suggest the normal state of the program should be
  3854.         ErrorMode(@CANCEL), especially if you are writing a batch file
  3855.         for others to use.  You can always suppress errors you expect
  3856.         will occur and then re-enable ErrorMode (@CANCEL).
  3857.  
  3858.  
  3859.  
  3860.  
  3861.                                                                        53
  3862.  
  3863.         WBL FUNCTION REFERENCE
  3864.  
  3865.  
  3866.  
  3867.         Example:
  3868.           ; Delete xxxtest.xyz.
  3869.           ; If file doesn't exist, continue execution; don't stop
  3870.           prevmode = ErrorMode(@OFF)
  3871.           FileDelete("c:\xxxtest.xyz")
  3872.           ErrorMode(prevmode)
  3873.  
  3874.         See Also:
  3875.           Debug, LastError
  3876.  
  3877.  
  3878.  
  3879.         Execute
  3880.  
  3881.         Executes a statement in a protected environment.  Any errors
  3882.         encountered are recoverable.
  3883.  
  3884.         Syntax:
  3885.           Execute statement
  3886.  
  3887.         Parameters:
  3888.           "statement" =  is (hopefully) an executable statement.
  3889.  
  3890.         Use this command to execute computed or user-entered statements.
  3891.         Due to the built-in error recovery associated with the Execute
  3892.         statement, it is ideal for interactive execution of user-entered
  3893.         commands.
  3894.  
  3895.         Note the Execute statement doesn't operate on a string per se,
  3896.         but rather on a direct statement.  If you want to put a code
  3897.         segment into a string variable you must use the substitution
  3898.         feature of the language, as in the example below.
  3899.  
  3900.         Example:
  3901.           cmd = ""
  3902.           cmd = AskLine("WBL Interactive", "Command:", cmd)
  3903.           execute %cmd%
  3904.  
  3905.  
  3906.  
  3907.         Exit
  3908.  
  3909.         Terminates the batch file being interpreted.
  3910.  
  3911.         Syntax:
  3912.           Exit
  3913.  
  3914.         Use this command to prematurely exit a batch file process.  An
  3915.         exit is implied at the end of each batch file.
  3916.  
  3917.         Example:
  3918.           a = 100
  3919.           message("The value of a is", a)
  3920.           exit
  3921.  
  3922.  
  3923.  
  3924.  
  3925.  
  3926.  
  3927.         54
  3928.  
  3929.                                                    WBL FUNCTION REFERENCE
  3930.  
  3931.  
  3932.  
  3933.         See Also:
  3934.           Pause
  3935.  
  3936.  
  3937.  
  3938.         Exclusive
  3939.  
  3940.         Controls whether or not other Windows program will get any time
  3941.         to execute.
  3942.  
  3943.         Syntax:
  3944.           Exclusive (mode)
  3945.  
  3946.         Parameters:
  3947.           mode =    @ON or @OFF.
  3948.  
  3949.         Returns:
  3950.           (integer) previous Exclusive mode.
  3951.  
  3952.         Exclusive(@ON) runs the fastest but does not allow other Windows
  3953.         applications to get much time.  Exclusive(@OFF) runs just a tad
  3954.         slower, is the default, and is nicely mannered to other
  3955.         applications.
  3956.  
  3957.         Example:
  3958.           ; We want Excel to get top processing priority
  3959.           RunZoom("excel.exe, "")
  3960.           Exclusive(@ON)
  3961.           ; When we're done with Excel, return to default mode
  3962.           WinWaitClose ("Microsoft Excel")
  3963.           Exclusive(@OFF)
  3964.  
  3965.  
  3966.  
  3967.         FileClose
  3968.  
  3969.         Closes a file.
  3970.  
  3971.         Syntax:
  3972.           Fileclose (filehandle)
  3973.  
  3974.         Parameters:
  3975.           filehandle = same integer that was returned by FileOpen.
  3976.  
  3977.         Returns:
  3978.           (integer) always 0.
  3979.  
  3980.         Example:
  3981.           ; the hard way to copy an ascii file
  3982.           old = FileOpen("config.sys", "READ")
  3983.           new = FileOpen("sample.txt", "WRITE")
  3984.           :top
  3985.           x = FileRead(old)
  3986.           If x != "*EOF*" Then FileWrite(new, x)
  3987.           If x != "*EOF*" Then Goto top
  3988.  
  3989.  
  3990.  
  3991.  
  3992.  
  3993.                                                                        55
  3994.  
  3995.         WBL FUNCTION REFERENCE
  3996.  
  3997.  
  3998.  
  3999.           FileClose(new)
  4000.           FileClose(old)
  4001.  
  4002.  
  4003.  
  4004.         FileCopy
  4005.  
  4006.         Copies files.
  4007.  
  4008.         Syntax:
  4009.           FileCopy (source-list, destination, warning)
  4010.  
  4011.         Parameters:
  4012.           "source-list" =   a string containing one or more filenames,
  4013.                     which may be wildcarded.
  4014.           "destination" =   target file name.
  4015.  
  4016.           warning = @TRUE if you want a warning before
  4017.                     overwriting existing files;
  4018.                     @FALSE if no warning desired.
  4019.  
  4020.         Returns:
  4021.           (integer)    @TRUE if all files were copied successfully;
  4022.                        @FALSE if at least one file wasn't copied.
  4023.  
  4024.         Use this command to copy an individual file, a group of files
  4025.         using wildcards, or several groups of files by separating the
  4026.         names with spaces.
  4027.         You can also copy files to any COM or LPT device.
  4028.  
  4029.         "Source-list" may contain * and ? wildcards.  "Destination" may
  4030.         contain the * wildcard only.
  4031.  
  4032.         Errors:
  4033.           1006 "File Copy/Move: No matching files found"
  4034.           2002 "File Copy/Move: 'From' file illegal"
  4035.           2003 "File Copy/Move: 'To'   file illegal"
  4036.           2004 "File Copy/Move: Cannot copy/move wildcards into fixed
  4037.                 root"
  4038.           2005 "File Copy/Move: Cannot copy/move wildcards into fixed
  4039.                 extension"
  4040.           3118 "FileCopyMove: Destination file same as source"
  4041.  
  4042.         Examples:
  4043.           FileCopy("c:\config.sys", "d:", @FALSE)
  4044.           FileCopy("c:\*.sys", "d:devices\*.sys", @TRUE)
  4045.           FileCopy("c:\config.sys", "LPT1:", @FALSE)
  4046.  
  4047.         See Also:
  4048.           FileDelete, FileExist, FileLocate, FileMove, FileRename
  4049.  
  4050.  
  4051.  
  4052.         FileDelete
  4053.  
  4054.         Deletes files.
  4055.  
  4056.  
  4057.  
  4058.         56
  4059.  
  4060.                                                    WBL FUNCTION REFERENCE
  4061.  
  4062.  
  4063.  
  4064.         Syntax:
  4065.           FileDelete (file-list)
  4066.  
  4067.         Parameters:
  4068.           "file-list" =  a string containing one or more filenames,
  4069.                     which may be wildcarded.
  4070.         Returns:
  4071.           (integer) @TRUE if all the files were deleted;
  4072.                     @FALSE if a file didn't exist or is marked with the
  4073.                     READ-ONLY attribute.
  4074.  
  4075.         Use this command to delete an individual file, a group of files
  4076.         using wildcards, or several groups of files by separating the
  4077.         names with spaces.
  4078.  
  4079.         Errors:
  4080.           1017 "File Delete: No matching files found"
  4081.           1018 "File Delete: Delete Failed"
  4082.           2016 "File Delete: File name illegal"
  4083.  
  4084.         Example:
  4085.           WasDeleted = FileDelete("badfile")
  4086.  
  4087.         See Also:
  4088.           FileExist, FileLocate, FileMove, FileRename
  4089.  
  4090.  
  4091.  
  4092.         FileExist
  4093.  
  4094.         Tests for the existence of files.
  4095.  
  4096.         Syntax:
  4097.           FileExist (filename)
  4098.  
  4099.         Parameters:
  4100.           "filename" = either a fully qualified filename with drive and
  4101.                     path, or just a filename and extension.
  4102.         Returns:
  4103.           (integer) @TRUE if the file exists;
  4104.                     @FALSE if it doesn't or if the pathname is invalid.
  4105.  
  4106.         This statement is used to test whether or not a specified file
  4107.         exists.
  4108.  
  4109.         If a fully qualified file name is used only the specified drive
  4110.         and directory will be checked for the desired file.  If only the
  4111.         root and extension are specified, then all the directories in the
  4112.         DOS PATH statement will be searched for the desired file.
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.                                                                        57
  4124.  
  4125.         WBL FUNCTION REFERENCE
  4126.  
  4127.  
  4128.  
  4129.         Example:
  4130.           ; check for file in current directory
  4131.           fex = FileExist(StrCat(DirGet(), "myfile.txt"))
  4132.           tex = StrSub("NOT", 1, StrLen("NOT") * fex)
  4133.           Message("MyFile.Txt"," Is %tex%in the current directory")
  4134.           ; check for file in someplace along path
  4135.           fex = FileExist("myfile.txt")
  4136.           tex = StrSub("NOT", 1, StrLen("NOT") * fex)
  4137.           Message("MyFile.Txt", " Is %tex% in the DOS path")
  4138.  
  4139.         See Also:
  4140.           FileLocate
  4141.  
  4142.  
  4143.  
  4144.         FileExtension
  4145.  
  4146.         Returns extension of file.
  4147.  
  4148.         Syntax:
  4149.           FileExtension (filename)
  4150.  
  4151.         Parameters:
  4152.           "filename" = [optional path]complete file name, with extension.
  4153.  
  4154.         FileExtension parses the passed filename and returns the
  4155.         extension part of the filename.
  4156.  
  4157.         Example:
  4158.           ; prevent the user from editing a COM or EXE file
  4159.           allfiles = FileItemize("*.*")
  4160.           editfile = ItemSelect("Select a file to edit", allfiles, " ")
  4161.           ext = FileExtension(editfile)
  4162.           If (ext == "com") || (ext == "exe") Then Goto noedit
  4163.           run("notepad.exe", editfile)
  4164.           exit
  4165.           :noedit
  4166.           Message ("Sorry", "You may not edit a program file")
  4167.  
  4168.  
  4169.  
  4170.         FileItemize
  4171.  
  4172.         Returns a space-delimited list of files.
  4173.  
  4174.         Syntax:
  4175.           FileItemize (file-list)
  4176.  
  4177.         Parameters:
  4178.           "file-list" =  a string containing a list of filenames, which
  4179.                     may be wildcarded.
  4180.  
  4181.         Returns:
  4182.           (string)  space-delimited list of files.
  4183.  
  4184.  
  4185.  
  4186.  
  4187.         58
  4188.  
  4189.                                                    WBL FUNCTION REFERENCE
  4190.  
  4191.  
  4192.  
  4193.  
  4194.         This function compiles a list of filenames and separates the
  4195.         names with spaces.
  4196.  
  4197.         FileItemize("*.BAK") ;returns all BAK's
  4198.         FileItemize("*.ARC *.ZIP *.LZH") ;returns list of compressed
  4199.         files
  4200.  
  4201.         This is especially useful in conjunction with the ItemSelect
  4202.         function, which enables the user to choose an item from such a
  4203.         space-delimited list.
  4204.  
  4205.         Examples:
  4206.           ; Get which .INI file to edit
  4207.           ifiles = FileItemize("c:\windows\*.ini")
  4208.           ifile = ItemSelect(".INI Files", ifiles, " ")
  4209.           RunZoom("notepad", ifile)
  4210.           Drop(ifiles, ifile)
  4211.  
  4212.         See Also:
  4213.           DirItemize, WinItemize, ItemSelect
  4214.  
  4215.  
  4216.  
  4217.         FileLocate
  4218.  
  4219.         Finds file in current directory or along the DOS PATH.
  4220.  
  4221.         Syntax:
  4222.           FileLocate (filename)
  4223.  
  4224.         Parameters:
  4225.           "filename" = root name, ".", and an extension.
  4226.  
  4227.         Returns:
  4228.           (string)  fully qualified path name.
  4229.  
  4230.         This function is used to obtain the fully qualified path name of
  4231.         a file.  The current directory is checked first, and if the file
  4232.         is not found the DOS path is searched.  This function returns the
  4233.         first occurrence of the file.
  4234.  
  4235.         Example:
  4236.           ; Edit WIN.INI
  4237.           winini = FileLocate("win.ini")
  4238.           If winini == "" Then Goto notfound
  4239.           Run("notepad.exe", winini)
  4240.           Exit
  4241.           :notfound
  4242.           Message("???", "WIN.INI not found")
  4243.  
  4244.         See Also:
  4245.           FileExist
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.                                                                        59
  4253.  
  4254.         WBL FUNCTION REFERENCE
  4255.  
  4256.  
  4257.  
  4258.         FileMove
  4259.  
  4260.         Moves files.
  4261.  
  4262.         Syntax:
  4263.           FileMove (source-list, destination, warning)
  4264.  
  4265.         Parameters:
  4266.           "source-list" =   one or more filenames separated by spaces.
  4267.           "destination" =   target filename.
  4268.           warning =         @TRUE if you want a warning before
  4269.                             overwriting existing files; @FALSE if no
  4270.                             warning desired.
  4271.  
  4272.         Returns:
  4273.           (integer) @TRUE if the file was moved;
  4274.                     @FALSE if the source file was not found or had the
  4275.                     READ-ONLY attribute, or the target filename is
  4276.                     invalid.
  4277.  
  4278.         Use this command to move an individual file, a group of files
  4279.         using wildcards, or several groups of files by separating the
  4280.         names with spaces.
  4281.  
  4282.         You can also move files to another drive, or to any COM or LPT
  4283.         device.
  4284.  
  4285.         "Source-list" may contain * and ? wildcards.  "Destination" may
  4286.         contain the * wildcard only.
  4287.  
  4288.         Errors:
  4289.           1006 "File Copy/Move: No matching files found"
  4290.           2002 "File Copy/Move: 'From' file illegal"
  4291.           2003 "File Copy/Move: 'To'   file illegal"
  4292.           2004 "File Copy/Move: Cannot copy/move wildcards into fixed
  4293.                 root"
  4294.           2005 "File Copy/Move: Cannot copy/move wildcards into fixed
  4295.                 extension"
  4296.           2007 "File Move: Unable to rename source file"
  4297.           2015 "File Move:  Unable to remove source file"
  4298.  
  4299.         Example:
  4300.           FileMove("c:\config.sys", "d:", @FALSE)
  4301.           FileMove("c:\*.sys", "d:*.sys", @TRUE)
  4302.  
  4303.         See Also:
  4304.           FileCopy, FileDelete, FileExist, FileLocate, FileRename
  4305.  
  4306.  
  4307.  
  4308.         FileOpen
  4309.  
  4310.         Opens a STANDARD ASCII (only) file for reading or writing.
  4311.  
  4312.         Syntax:
  4313.           Fileopen ( filename, open-type)
  4314.  
  4315.  
  4316.  
  4317.         60
  4318.  
  4319.                                                    WBL FUNCTION REFERENCE
  4320.  
  4321.  
  4322.  
  4323.         Parameters:
  4324.           "filename" = name of the file to open.
  4325.           open-type =  READ or WRITE.
  4326.  
  4327.         Returns:
  4328.           (special integer) filehandle
  4329.  
  4330.         The filehandle returned by the FileOpen function is subsequently
  4331.         used by the FileRead,FileWrite and FileClose functions.
  4332.  
  4333.         Examples:
  4334.  
  4335.         To open for reading:
  4336.           FileOpen("stuff.txt", "READ")
  4337.  
  4338.         To open for writing:
  4339.           FileOpen("stuff.txt", "WRITE")
  4340.  
  4341.  
  4342.  
  4343.         FilePath
  4344.  
  4345.         Returns path of file.
  4346.  
  4347.         Syntax:
  4348.           FilePath (filename)
  4349.  
  4350.         Parameters:
  4351.           "filename" = fully qualified file name, including path.
  4352.  
  4353.         FilePath parses the passed filename and returns the drive and
  4354.         path of the file specification, if any.
  4355.  
  4356.         Example:
  4357.           coms = environment("comspec")
  4358.           compath = FilePath(coms)
  4359.           Message("", "Your command processor is located in the
  4360.             %compath% directory")
  4361.  
  4362.  
  4363.  
  4364.         FileRead
  4365.  
  4366.         Reads data from a file.
  4367.  
  4368.         Syntax:
  4369.           Fileread(filehandle)
  4370.  
  4371.         Parameters:
  4372.           filehandle = same integer that was returned by FileOpen.
  4373.  
  4374.         Returns:
  4375.           (string)  line of data read from file.
  4376.  
  4377.         At EOF the string *EOF* will be returned.
  4378.  
  4379.         Example:
  4380.           handle = FileOpen("autoexec.bat", "READ")
  4381.  
  4382.                                                                        61
  4383.  
  4384.         WBL FUNCTION REFERENCE
  4385.  
  4386.  
  4387.  
  4388.           :top
  4389.           line = FileRead(handle)
  4390.           Display(4, "AUTOEXEC DATA", line)
  4391.           If line != "*EOF*" Then Goto top
  4392.           FileClose(handle)
  4393.  
  4394.  
  4395.  
  4396.         FileRename
  4397.  
  4398.         Renames files.
  4399.  
  4400.         Syntax:
  4401.           FileRename (source-list, destination)
  4402.  
  4403.         Parameters:
  4404.           "source-list" =   one or more filenames separated by spaces.
  4405.           "destination" =   target filename.
  4406.  
  4407.         Returns:
  4408.           (integer) @TRUE if the file was renamed;
  4409.                     @FALSE if the source file was not found or had the
  4410.                     READ-ONLY attribute, or the target filename is
  4411.                     invalid.
  4412.  
  4413.         Use this command to rename an individual file, a group of files
  4414.         using wildcards, or several groups of files by separating the
  4415.         names with spaces.
  4416.         Note: Unlike FileMove, you cannot make a file change its resident
  4417.         disk drive with FileRename.
  4418.  
  4419.         "Source-list" may contain * and ? wildcards.  "Destination" may
  4420.         contain the * wildcard only.
  4421.  
  4422.         Errors:
  4423.           1024 "File Rename: No matching files found"
  4424.           1025 "File Rename: Rename failed"
  4425.           2019 "File Rename: 'From' file illegal"
  4426.           2020 "File Rename: 'To' file illegal"
  4427.           2021 "File Rename: Attempt to rename across drive boundary. -
  4428.                 Use MOVE instead."
  4429.           2022 "File Rename: Cannot rename wildcards into a fixed
  4430.                 filename root"
  4431.           2023 "File Rename: Cannot rename wildcards into a fixed
  4432.                 filename extension"
  4433.  
  4434.         Example:
  4435.           FileRename("c:\config.sys", "config.old")
  4436.           FileRename("c:\*.txt", "*.bak")
  4437.  
  4438.         See Also:
  4439.           FileCopy, FileExist, FileLocate, FileMove
  4440.  
  4441.  
  4442.  
  4443.  
  4444.  
  4445.  
  4446.  
  4447.  
  4448.         62
  4449.  
  4450.                                                    WBL FUNCTION REFERENCE
  4451.  
  4452.  
  4453.  
  4454.         FileRoot
  4455.  
  4456.         Returns root of file.
  4457.  
  4458.         Syntax:
  4459.           FileRoot (filename)
  4460.  
  4461.         Parameters:
  4462.           "filename" = [optional path]complete file name, with extension.
  4463.  
  4464.         FileRoot parses the passed filename and returns the root part of
  4465.         the filename.
  4466.  
  4467.         Example:
  4468.           allfiles = FileItemize("*.*")
  4469.           editfile = ItemSelect("Select a file to edit", allfiles, " ")
  4470.           root = FileRoot(editfile)
  4471.           ext = FileExtension(editfile)
  4472.           lowerext = StrLower(ext)
  4473.           nicefile = StrCat(root, ".", lowerext)
  4474.           Message("", "You are about to edit %nicefile%.")
  4475.           run("notepad.exe", editfile)
  4476.  
  4477.  
  4478.  
  4479.         FileSize
  4480.  
  4481.         Finds the total size of a group of files.
  4482.  
  4483.         Syntax:
  4484.           FileSize (file-list)
  4485.  
  4486.         Parameters:
  4487.           "file-list" =  zero or more filenames, separated by spaces.
  4488.  
  4489.         Returns:
  4490.           (integer) total bytes taken up by the specified files.
  4491.  
  4492.         This function returns the total size of the specified files.
  4493.         Note it doesn't handle wildcarded filenames.  You can, however,
  4494.         use FileItemize on a wildcarded filename and use the resulting
  4495.         string with as a FileSize parameter.
  4496.  
  4497.         Errors:
  4498.           3112 "FileSize:  File Not Found"
  4499.  
  4500.         Example:
  4501.           size = FileSize(FileItemize(""))
  4502.           Message("Size of Highlighted Files", size)
  4503.  
  4504.         See Also:
  4505.           DiskFree
  4506.  
  4507.  
  4508.  
  4509.  
  4510.  
  4511.  
  4512.  
  4513.  
  4514.                                                                        63
  4515.  
  4516.         WBL FUNCTION REFERENCE
  4517.  
  4518.  
  4519.  
  4520.         FileWrite
  4521.  
  4522.         Writes data to a file.
  4523.  
  4524.         Syntax:
  4525.           Filewrite(filehandle,output-data)
  4526.  
  4527.         Parameters:
  4528.           filehandle = same integer that was returned by FileOpen.
  4529.           "output-data" =   data to write to file.
  4530.  
  4531.         Returns:
  4532.           (integer) always 0.
  4533.  
  4534.         Example:
  4535.           handle = FileOpen("stuff.txt", "WRITE")
  4536.           FileWrite(handle, "Gobbledygook")
  4537.           FileClose(handle)
  4538.  
  4539.  
  4540.  
  4541.         Goto
  4542.  
  4543.         Changes the flow of control in a batch file.
  4544.  
  4545.         Syntax:
  4546.           Goto label
  4547.  
  4548.         Parameters:
  4549.           "label" = user-defined identifier.
  4550.  
  4551.         Note:  labels begin with a colon (:)
  4552.  
  4553.         Example:
  4554.           a = 0
  4555.           :loop
  4556.           If A > 5 Then Goto next
  4557.           Message("A is now", a)
  4558.           a = a + 1
  4559.           Goto loop
  4560.           :next
  4561.           Message("DONE", "Loop Exited")
  4562.  
  4563.  
  4564.  
  4565.         If_Then
  4566.  
  4567.         Conditionally performs a function.
  4568.  
  4569.         Syntax:
  4570.           If condition Then statement
  4571.  
  4572.         If the condition following the If keyword is true, the statement
  4573.         following the Then keyword is executed.  If the condition
  4574.         following the If keyword is false, the statement following the
  4575.         Then keyword is ignored.
  4576.  
  4577.  
  4578.  
  4579.         64
  4580.  
  4581.                                                    WBL FUNCTION REFERENCE
  4582.  
  4583.  
  4584.         Example:
  4585.           If a > 5 Then Message("Hello", "A GT 5")
  4586.  
  4587.  
  4588.         IgnoreInput
  4589.  
  4590.         Turns off hardware input to windows.
  4591.  
  4592.         Syntax:
  4593.           IgnoreInput(mode)
  4594.  
  4595.         Parameters:
  4596.           mode =    @TRUE or @FALSE.
  4597.  
  4598.         Returns:
  4599.           (integer) previous IgnoreInput mode.
  4600.  
  4601.         IgnoreInput causes mouse movements, clicks and keyboard entry to
  4602.         be completely ignored.  Good for self-running demos.
  4603.  
  4604.         Warning: If you are not careful with the use of IgnoreInput, you
  4605.         can hang your machine.
  4606.  
  4607.         Example:
  4608.           username = AskLine("Hello", "Please enter your name","")
  4609.           IgnoreInput(@TRUE)
  4610.           Call("demo.wbt", "username")
  4611.           IgnoreInput(@FALSE)
  4612.  
  4613.         IniRead
  4614.  
  4615.         Reads data from the WIN.INI file.
  4616.  
  4617.         Syntax:
  4618.           IniRead (section, keyname, default)
  4619.  
  4620.         Parameters:
  4621.           "section" =  the major heading to read the data from.
  4622.           "keyname =   the name of the item to read.
  4623.           "default" =  string to return if the desired item is not found.
  4624.  
  4625.         Returns:
  4626.           (string)  data from WIN.INI file.
  4627.  
  4628.         This command allows a program to read data from the WIN.INI file.
  4629.         The WIN.INI file has the form:
  4630.  
  4631.           [section]
  4632.           keyname=settings
  4633.  
  4634.         Most of the entries in WIN.INI are set from the Windows Control
  4635.         Panel program, but individual applications can also use it to
  4636.         store option settings in their own sections.
  4637.                                                                        65
  4638.  
  4639.         WBL FUNCTION REFERENCE
  4640.  
  4641.  
  4642.  
  4643.         Example:
  4644.           ; Find the default output device:
  4645.           a = IniRead("windows", "device", "No Default")
  4646.           Message("Default Output Device", a)
  4647.  
  4648.         See Also:
  4649.           Environment, IniWrite
  4650.  
  4651.  
  4652.  
  4653.         IniReadPvt
  4654.  
  4655.         For reading private ini files.
  4656.  
  4657.         Syntax:
  4658.           IniReadPvt (section, keyname, default,filename)
  4659.  
  4660.         Parameters:
  4661.           "section" =  the major heading to read the data from.
  4662.           "keyname =   the name of the item to read.
  4663.           "default" =  string to return if the desired item is not found.
  4664.           "filename" = name of the INI file.
  4665.  
  4666.         Returns:
  4667.           (string)  data from the INI file.
  4668.  
  4669.         Looks up a value in the "filename" ini file.  If the value is not
  4670.         found, the "default" will be returned.
  4671.  
  4672.         Example:
  4673.         Given the following segment from WB.INI
  4674.  
  4675.           [Main]
  4676.           Lang=German
  4677.  
  4678.         The statement:
  4679.  
  4680.           IniReadPvt("Main", "Lang", "English", "WB.INI")
  4681.  
  4682.         would return "German"
  4683.  
  4684.  
  4685.  
  4686.         IniWrite
  4687.  
  4688.         Writes data to the WIN.INI file.
  4689.  
  4690.         Syntax:
  4691.           IniWrite (section, keyname, data)
  4692.  
  4693.         Parameters:
  4694.           "section" =  major heading to write the data to.
  4695.           "keyname =   name of the data item to write.
  4696.           "data" =  string to write to the WIN.INI file.
  4697.  
  4698.         Returns:
  4699.           (integer) always @TRUE.
  4700.  
  4701.         66
  4702.  
  4703.                                                    WBL FUNCTION REFERENCE
  4704.  
  4705.  
  4706.  
  4707.  
  4708.         This command allows a program to write data to the WIN.INI file.
  4709.         The "section" is added to the file if it doesn't already exist.
  4710.  
  4711.         Example:
  4712.           ; Change the list of pgms to load upon Windows startup:
  4713.           loadprogs = IniRead("windows", "load", "")
  4714.           newprogs = AskLine("Add Pgm To LOAD= Line", "Add:", loadprogs)
  4715.           IniWrite("windows", "load", newprogs)
  4716.  
  4717.         See Also:
  4718.           IniRead
  4719.  
  4720.  
  4721.  
  4722.         IniWritePvt
  4723.  
  4724.         For writing private ini files.
  4725.  
  4726.         Syntax:
  4727.           IniWritePvt (section, keyname, data, filename)
  4728.  
  4729.         Parameters:
  4730.           "section" =  major heading to write the data to.
  4731.           "keyname =   name of the data item to write.
  4732.           "data" =  string to write to the INI file.
  4733.           "filename" = name of the INI file.
  4734.  
  4735.         Writes a value in the "filename" ini file.
  4736.  
  4737.         Example:
  4738.         The statement:
  4739.  
  4740.           IniWritePvt("Main", "Lang", "French, "WB.INI")
  4741.  
  4742.         would create the following entry in WB.INI:
  4743.  
  4744.           [Main]
  4745.           Lang=French
  4746.  
  4747.  
  4748.  
  4749.         IsDefined
  4750.  
  4751.         Determines if a variable name is currently defined.
  4752.  
  4753.         Syntax:
  4754.           IsDefined (var)
  4755.  
  4756.         Parameters:
  4757.           "var" =   a variable name.
  4758.  
  4759.         Returns:
  4760.           (integer) @YES if the variable is currently defined;
  4761.                     @NO if it was never defined or has been dropped.
  4762.  
  4763.  
  4764.  
  4765.  
  4766.  
  4767.                                                                        67
  4768.  
  4769.         WBL FUNCTION REFERENCE
  4770.  
  4771.  
  4772.  
  4773.         A variable is defined the first time it appears at the left of an
  4774.         equal sign in a statement.  It stays defined until it is
  4775.         explicitly Dropped.
  4776.  
  4777.         Example:
  4778.           def = IsDefined(thisvar)
  4779.           If def == @FALSE Then Message("ERROR!", "Variable not
  4780.             defined")
  4781.  
  4782.         See Also:
  4783.           Drop
  4784.  
  4785.  
  4786.  
  4787.         IsKeyDown
  4788.  
  4789.         Tells about keys/mouse.
  4790.  
  4791.         Syntax:
  4792.           IsKeyDown(keycodes)
  4793.  
  4794.         Parameters:
  4795.           keycodes =   @SHIFT and/or @CTRL
  4796.  
  4797.         Returns:
  4798.           (integer) @YES if the key is down.
  4799.                     @NO if the key is not down.
  4800.  
  4801.         Determines if the SHIFT key or the CTRL key is currently down.
  4802.         Note: Right mouse button is the same as SHIFT, and  Middle mouse
  4803.         button is the same as CTRL.
  4804.  
  4805.         Examples:
  4806.  
  4807.           IsKeyDown(@SHIFT)
  4808.           IsKeyDown(@CTRL)
  4809.           IsKeyDown(@CTRL | @SHIFT)
  4810.           IsKeyDown(@CTRL & @SHIFT)
  4811.  
  4812.  
  4813.  
  4814.         IsLicensed
  4815.  
  4816.         Tells if WinBatch is licensed.
  4817.  
  4818.         Syntax:
  4819.           IsLicensed()
  4820.  
  4821.         Returns:
  4822.           (integer) @YES if current version of WinBatch is licensed.
  4823.                     @NO if current version of WinBatch is not licensed.
  4824.  
  4825.         Returns whether or not the current version of WinBatch is a
  4826.         licensed copy or not.
  4827.  
  4828.  
  4829.  
  4830.  
  4831.  
  4832.  
  4833.         68
  4834.  
  4835.                                                    WBL FUNCTION REFERENCE
  4836.  
  4837.  
  4838.  
  4839.         Example:
  4840.           IsLicensed()
  4841.  
  4842.  
  4843.  
  4844.         IsNumber
  4845.  
  4846.         Determines whether a variable contains a valid number.
  4847.  
  4848.         Syntax:
  4849.           IsNumber (string)
  4850.  
  4851.         Parameters:
  4852.           "string" =   string to test to see if it represents a valid
  4853.                        number.
  4854.  
  4855.         Returns:
  4856.           (integer) @YES if it contains a valid number;
  4857.                     @NO if it doesn't.
  4858.  
  4859.         This function determines if a string variable contains a valid
  4860.         integer.  Useful for checking user input prior to using it in
  4861.         computations.
  4862.  
  4863.         Example:
  4864.           a = AskLine("ISNUMBER", "Enter a number", "0")
  4865.           If IsNumber(a) == @NO Then Message("", "You didn't enter a
  4866.             number")
  4867.  
  4868.         See Also:
  4869.           Abs, Char2Num
  4870.  
  4871.  
  4872.  
  4873.         ItemSelect
  4874.  
  4875.         Allows the user to choose an item from a listbox.
  4876.  
  4877.         Syntax:
  4878.           ItemSelect (title, list, delimiter)
  4879.  
  4880.         Parameters:
  4881.           "title" = the title of dialog box to display.
  4882.           "list" =  a string containing a list of items to choose from.
  4883.           "delimiter" =  a string containing the character to act as
  4884.                     delimiter between items in the list.
  4885.  
  4886.         Returns:
  4887.           (string)  the selected item.
  4888.  
  4889.         This function displays a dialog box with a listbox inside.  This
  4890.         listbox is filled with a list of items taken from a string you
  4891.         provide to the function.
  4892.         Each item in the string must be separated ("delimited") by a
  4893.         character, which you also pass to the function.
  4894.  
  4895.  
  4896.  
  4897.  
  4898.                                                                        69
  4899.  
  4900.         WBL FUNCTION REFERENCE
  4901.  
  4902.  
  4903.  
  4904.         The user selects one of the items by either doubleclicking on it,
  4905.         or single-clicking and pressing OK.  The item is returned as a
  4906.         string.
  4907.  
  4908.         If you create the list with the FileItemize or DirItemize
  4909.         functions you will be using a space-delimited list.  WinItemize,
  4910.         however, creates a tab-delimited list of window titles since
  4911.         titles can have embedded blanks.
  4912.  
  4913.         Example:
  4914.           Files = FileItemize("*.bmp")
  4915.           thefile = ItemSelect("Bitmap Files", Files, " ")
  4916.           Run("pbrush.exe", thefile)
  4917.  
  4918.         See Also:
  4919.           AskYesNo, Display,  DirItemize, FileItemize, WinItemize,
  4920.           Message, Pause, TextBox
  4921.  
  4922.  
  4923.  
  4924.         LastError
  4925.  
  4926.         Returns the most-recent error encountered during the current
  4927.         batch file.
  4928.  
  4929.         Syntax:
  4930.           LastError ( )
  4931.  
  4932.         Returns:
  4933.           (integer) most-recent WBL error code encountered.
  4934.  
  4935.         WBL errors are numbered according to their severity.  "Minor"
  4936.         errors go from 1000 through 1999.  Moderate errors are 2000
  4937.         through 2999.  Fatal errors are numbered 3000 to 3999.
  4938.         Depending on which error mode is active when an error occurs, you
  4939.         may not get a chance to check the error code.  See ErrorMode for
  4940.         a discussion of default error handling.
  4941.  
  4942.         Don't bother checking for "fatal" error codes.  When a fatal
  4943.         error occurs, the batch file is canceled before the next WBL
  4944.         statement gets to execute (regardless of which error mode is
  4945.         active).
  4946.  
  4947.         Calling LastError itself resets the last error indicator back to
  4948.         zero.
  4949.  
  4950.         A full listing of possible errors you can encounter in processing
  4951.         a batch file is in Appendix B - Errors.
  4952.  
  4953.         Example:
  4954.           ErrorMode(@OFF)
  4955.           FileCopy("data.dat", "c:\backups", @FALSE)
  4956.           ErrorMode(@CANCEL)
  4957.           If LastError() == 1006 Then Message("Error", "Please call Tech
  4958.             Support at 555-9999.")
  4959.  
  4960.  
  4961.  
  4962.  
  4963.  
  4964.         70
  4965.  
  4966.                                                    WBL FUNCTION REFERENCE
  4967.  
  4968.  
  4969.  
  4970.         See Also:
  4971.           Debug, ErrorMode
  4972.  
  4973.  
  4974.  
  4975.         LogDisk
  4976.  
  4977.         Logs (activates) a disk drive.
  4978.  
  4979.         Syntax:
  4980.           LogDisk (drive-letter)
  4981.  
  4982.         Parameters:
  4983.           "drive-letter" =  is the disk drive to log into.
  4984.  
  4985.         Returns:
  4986.           (integer) @TRUE if the current drive was changed;
  4987.                     @FALSE if the drive doesn't exist.
  4988.  
  4989.         Use this command to change the logged disk drive.
  4990.  
  4991.         This command produces the same effect as if you typed the drive
  4992.         name from the DOS command prompt.
  4993.  
  4994.         Errors:
  4995.           1028 "LogDisk: Requested drive not online"
  4996.  
  4997.         Example:
  4998.           logdisk("c:")
  4999.  
  5000.         See Also:
  5001.           DirChange
  5002.  
  5003.  
  5004.  
  5005.         Max
  5006.  
  5007.         Returns largest number in a list of numbers.
  5008.  
  5009.         Syntax:
  5010.           Max (integer [, integer]...)
  5011.  
  5012.         Parameters:
  5013.           integer = number.
  5014.  
  5015.         Returns:
  5016.           (integer) largest parameter.
  5017.  
  5018.         Use this function to determine the largest of a set of numbers.
  5019.  
  5020.         Example:
  5021.           a = Max(5, -37, 125, 34, 2345, -32767)
  5022.           Message("Largest number is", a)
  5023.  
  5024.         See Also:
  5025.           Abs, Average, Min
  5026.  
  5027.  
  5028.  
  5029.                                                                        71
  5030.  
  5031.         WBL FUNCTION REFERENCE
  5032.  
  5033.  
  5034.  
  5035.         Message
  5036.  
  5037.         Displays a message to the user.
  5038.  
  5039.         Syntax:
  5040.           Message (title, text)
  5041.  
  5042.         Parameters:
  5043.           "title" = title of the message box.
  5044.           "text" =  text to display in the message box.
  5045.  
  5046.         Returns:
  5047.           (integer) always @TRUE.
  5048.  
  5049.         Use this command to display a message to the user.  The user must
  5050.         respond by selecting the OK button before processing will
  5051.         continue.
  5052.  
  5053.         Example:
  5054.           Message("GUESSIT", "Pick a number between 1 and 100")
  5055.           Message("GUESSIT", "Multiply your number by 2")
  5056.           Message("GUESSIT", "Add 34")
  5057.           Message("GUESSIT", "Divide by 2")
  5058.           Message("GUESSIT", "Subtract your original number")
  5059.           Message("GUESSIT", "Your answer is 17")
  5060.  
  5061.         See Also:
  5062.           Display, Pause
  5063.  
  5064.  
  5065.  
  5066.         Min
  5067.  
  5068.         Returns lowest number in a list of numbers.
  5069.  
  5070.         Syntax:
  5071.           Min (integer [, integer]...)
  5072.  
  5073.         Parameters:
  5074.           integer = any integer number.
  5075.  
  5076.         Returns:
  5077.           (integer) lowest parameter.
  5078.  
  5079.         Use this function to determine the lowest of a set of integers.
  5080.  
  5081.         Example:
  5082.           a = Min( 5, -37, 125, 34, 2345, -32767)
  5083.           Message("Smallest number is", a)
  5084.  
  5085.         See Also:
  5086.           Abs, Average, Max
  5087.  
  5088.  
  5089.  
  5090.  
  5091.  
  5092.  
  5093.  
  5094.  
  5095.         72
  5096.  
  5097.                                                    WBL FUNCTION REFERENCE
  5098.  
  5099.  
  5100.  
  5101.         Num2Char
  5102.  
  5103.         Converts a number to its character equivalent.
  5104.  
  5105.         Syntax:
  5106.           Num2Char (integer)
  5107.  
  5108.         Parameters:
  5109.           number =  any number from 0 to 255.
  5110.  
  5111.         Returns:
  5112.           (string)  one-byte string containing the character the number
  5113.                     represents.
  5114.  
  5115.         Use this command to convert a number to its ASCII equivalent.
  5116.  
  5117.         Example:
  5118.           ; Build a variable containing a CRLF combo
  5119.           crlf = StrCat(Num2Char(13), Num2Char(10))
  5120.           Message("NUM2CHAR", StrCat("line1", crlf, "line2"))
  5121.  
  5122.         See Also:
  5123.           Char2Num
  5124.  
  5125.  
  5126.  
  5127.         ParseData
  5128.  
  5129.         Parses the passed string, just like passed parameters are parsed.
  5130.  
  5131.         Syntax:
  5132.           Parsedata (string)
  5133.  
  5134.         Parameters:
  5135.           "string" =   string to be parsed.
  5136.  
  5137.         Variables show up as param1, param2, etc.  Param0 is the count of
  5138.         the number of parameters.
  5139.  
  5140.         Example:
  5141.           username = AskLine("Hello", "Please enter your name","")
  5142.           ParseData(username)
  5143.  
  5144.         If the user entered
  5145.  
  5146.           Joe Q. User
  5147.  
  5148.         ParseData would create the following variables:
  5149.  
  5150.              param0 == 3
  5151.              param1 == "Joe"
  5152.              param2 == "Q."
  5153.              param3 == "User"
  5154.  
  5155.  
  5156.  
  5157.  
  5158.  
  5159.  
  5160.  
  5161.                                                                        73
  5162.  
  5163.         WBL FUNCTION REFERENCE
  5164.  
  5165.  
  5166.  
  5167.         Pause
  5168.  
  5169.         Provides a message to user.  User may cancel processing.
  5170.  
  5171.         Syntax:
  5172.           Pause (title, text)
  5173.  
  5174.         Parameters:
  5175.           "title" = title of pause box.
  5176.           "text" =  text of the message to be displayed.
  5177.  
  5178.         Returns:
  5179.           (integer)    always @TRUE.
  5180.  
  5181.         This command displays a message to the user with an exclamation
  5182.         point icon.  The user may respond by selecting the OK button, or
  5183.         they may cancel the processing by selecting CANCEL.
  5184.  
  5185.         The Pause command is similar to the Message command except for
  5186.         the addition of the CANCEL button and icon.
  5187.  
  5188.         Example:
  5189.           Pause("Change Disks", "Insert new disk into Drive A:")
  5190.  
  5191.         See Also:
  5192.           Display, Message
  5193.  
  5194.  
  5195.  
  5196.         Random
  5197.  
  5198.         Computes a pseudo-random number.
  5199.  
  5200.         Syntax:
  5201.           Random (max)
  5202.  
  5203.         Parameters:
  5204.           max =     largest desired number.
  5205.  
  5206.         Returns:
  5207.           (integer) unpredictable positive number.
  5208.  
  5209.         This function will return a random integer between 0 and "max".
  5210.  
  5211.         Example:
  5212.           a = Random(79)
  5213.           Message("Random number between 0 and 79", a)
  5214.  
  5215.  
  5216.  
  5217.         Return
  5218.  
  5219.         Used to return from a Call or a CallExt to the calling program.
  5220.  
  5221.         Syntax:
  5222.           Return
  5223.  
  5224.  
  5225.  
  5226.         74
  5227.  
  5228.                                                    WBL FUNCTION REFERENCE
  5229.  
  5230.  
  5231.  
  5232.         If the program was not called, then an EXIT is assumed.
  5233.  
  5234.         Example:
  5235.           Display(2, "End of subroutine", "Returning to MAIN.WBT")
  5236.           Return
  5237.  
  5238.  
  5239.  
  5240.         Run
  5241.  
  5242.         Runs a program as a normal window.
  5243.  
  5244.         Syntax:
  5245.           Run (program-name, parameters)
  5246.  
  5247.         Parameters:
  5248.           "program-name" =the name of the desired .EXE, .COM, .PIF, .BAT
  5249.                     file, or a data file.
  5250.           "parameters" = optional parameters as required by the applica-
  5251.                     tion.
  5252.  
  5253.         Returns:
  5254.           (integer) @TRUE if the program was found;
  5255.                     @FALSE if it wasn't.
  5256.  
  5257.         Use this command to run an application.
  5258.  
  5259.         If the drive and path are not part of the program name, the
  5260.         current directory will be examined first and then the DOS path
  5261.         will be searched to find the desired executable file.
  5262.  
  5263.         If the "program-name" doesn't have an extension of .EXE, .COM,
  5264.         .PIF, or .BAT, it will be run in accordance with whatever is in
  5265.         the [extensions] section of the WIN.INI file.  When this happens,
  5266.         any "parameters" you specified are ignored.
  5267.  
  5268.         Examples:
  5269.           Run("notepad.exe", "abc.txt")
  5270.           Run("clock.exe", "")
  5271.           Run("paint.exe", "pict.msp")
  5272.  
  5273.         See Also:
  5274.           RunHide, RunIcon, RunZoom, WinClose, WinWaitClose
  5275.  
  5276.  
  5277.  
  5278.         RunHide
  5279.  
  5280.         Runs a program as a hidden window.
  5281.  
  5282.         Syntax:
  5283.           RunHide (program-name, parameters)
  5284.  
  5285.         Parameters:
  5286.           "program-name" =the name of the desired .EXE, .COM, .PIF, .BAT
  5287.                     file, or a data file.
  5288.           "parameters" = optional parameters as required by the
  5289.                     application.
  5290.  
  5291.  
  5292.                                                                        75
  5293.  
  5294.         WBL FUNCTION REFERENCE
  5295.  
  5296.  
  5297.  
  5298.         Returns:
  5299.           (integer) @TRUE if the program was found;
  5300.                     @FALSE if it wasn't.
  5301.  
  5302.         Use this command to run an application as a hidden window.
  5303.  
  5304.         If the drive and path are not part of the program name, the
  5305.         current directory will be examined first and then the DOS path
  5306.         will be searched to find the desired executable file.
  5307.  
  5308.         If the "program-name" doesn't have an extension of .EXE, .COM,
  5309.         .PIF, or .BAT, it will be run in accordance with whatever is in
  5310.         the [extensions] section of the WIN.INI file.  When this happens,
  5311.         any "parameters" you specified are ignored.
  5312.  
  5313.         Note:  When this command launches an application it informs it
  5314.         that you want it to run as a hidden window.  Whether or not the
  5315.         application honors your wish is beyond RunHide's control.
  5316.  
  5317.         Examples:
  5318.           RunHide("notepad.exe", "abc.txt")
  5319.           RunHide("clock.exe", "")
  5320.           RunHide("paint.exe", "pict.msp")
  5321.  
  5322.         See Also:
  5323.           Run, RunIcon, RunZoom, WinHide, WinClose, WinWaitClose
  5324.  
  5325.  
  5326.  
  5327.         RunIcon
  5328.  
  5329.         Runs a program as an iconic (minimized) window.
  5330.  
  5331.         Syntax:
  5332.           RunIcon (program-name, parameters)
  5333.  
  5334.         Parameters:
  5335.           "program-name" =the name of the desired .EXE, .COM, .PIF, .BAT
  5336.                     file, or a data file.
  5337.           "parameters" = optional parameters as required by the
  5338.                     application.
  5339.         Returns:
  5340.           (integer) @TRUE if the program was found;
  5341.                     @FALSE if it wasn't.
  5342.  
  5343.         Use this command to run an application as an icon.
  5344.  
  5345.         If the drive and path are not part of the program name, the
  5346.         current directory will be examined first and then the DOS path
  5347.         will be searched to find the desired executable file.
  5348.  
  5349.         If the "program-name" doesn't have an extension of .EXE, .COM,
  5350.         .PIF, or .BAT, it will be run in accordance with whatever is in
  5351.         the [extensions] section of the WIN.INI file.  When this happens,
  5352.         any "parameters" you specified are ignored.
  5353.  
  5354.  
  5355.  
  5356.  
  5357.         76
  5358.  
  5359.                                                    WBL FUNCTION REFERENCE
  5360.  
  5361.  
  5362.  
  5363.         Note:  When this command launches an application it merely
  5364.         informs it that you want it to begin as an icon.  Whether or not
  5365.         the application honors your wish is beyond RunIcon's control.
  5366.  
  5367.         Examples:
  5368.           RunIcon("notepad.exe", "abc.txt")
  5369.           RunIcon("clock.exe", "")
  5370.           RunIcon("paint.exe", "pict.msp")
  5371.  
  5372.         See Also:
  5373.           Run, RunHide, RunZoom, WinIconize, WinClose, WinWaitClose
  5374.  
  5375.  
  5376.  
  5377.         RunZoom
  5378.  
  5379.         Runs a program as a full-screen (maximized) window.
  5380.  
  5381.         Syntax:
  5382.           RunZoom (program-name, parameters)
  5383.  
  5384.         Parameters:
  5385.           "program-name" =the name of the desired .EXE, .COM, .PIF, .BAT
  5386.                     file, or a data file.
  5387.           "parameters" = optional parameters as required by the
  5388.                     application.
  5389.  
  5390.         Returns:
  5391.           (integer) @TRUE if the program was found;
  5392.                     @FALSE if it wasn't.
  5393.  
  5394.         Use this command to run an application as a full-screen window.
  5395.         If the drive and path are not part of the program name, the
  5396.         current directory will be examined first and then the DOS path
  5397.         will be searched to find the desired executable file.
  5398.  
  5399.         If the "program-name" doesn't have an extension of .EXE, .COM,
  5400.         .PIF, or .BAT, it will be run in accordance with whatever is in
  5401.         the [extensions] section of the WIN.INI file.  When this happens,
  5402.         any "parameters" you specified are ignored.
  5403.         Note:  When this command launches an application it merely
  5404.         informs it that you want it to be maximized to full-screen.
  5405.         Whether or not the application honors your wish is beyond
  5406.         RunZoom's control.
  5407.  
  5408.         Examples:
  5409.           RunZoom("notepad.exe", "abc.txt")
  5410.           RunZoom("clock.exe", "")
  5411.           RunZoom("paint.exe", "pict.msp")
  5412.  
  5413.         See Also:
  5414.           Run, RunHide, RunIcon, WinZoom, WinClose, WinWaitClose
  5415.  
  5416.  
  5417.  
  5418.  
  5419.  
  5420.  
  5421.                                                                        77
  5422.  
  5423.         WBL FUNCTION REFERENCE
  5424.  
  5425.  
  5426.  
  5427.         SendKey
  5428.  
  5429.         Sends keystrokes to the active application.
  5430.  
  5431.         Syntax:
  5432.           Sendkey (character-codes)
  5433.  
  5434.         Parameters:
  5435.           "character-codes" = string of regular and special characters
  5436.                     (see below).
  5437.         Returns:
  5438.           (integer) always 0
  5439.  
  5440.         SendKey is used to send keystrokes to the current window, just as
  5441.         if they had been entered from the keyboard.  Any alphanumeric
  5442.         character may be sent by simply placing the character in the
  5443.         string.  In addition, the following special characters may be
  5444.         used:
  5445.  
  5446.           Backspace {BACKSPACE} or {BS}
  5447.           Break     {BREAK}
  5448.           Clear     {CLEAR}
  5449.           Delete    {DELETE} or {DEL}
  5450.           Down Arrow   {DOWN}
  5451.           End       {END}
  5452.           ENTER     {ENTER} or ~
  5453.           Escape    {ESCAPE} or {ESC}
  5454.           F1 through F12 {F1} through {F12}
  5455.           Help      {HELP}
  5456.           Home      {HOME}
  5457.           Insert    {INSERT}
  5458.           Left Arrow   {LEFT}
  5459.           Page Down {PGDN}
  5460.           Page Up   {PGUP}
  5461.           Print Screen {PRTSC}
  5462.           Right Arrow  {RIGHT}
  5463.           Space     {SPACE} or {SP}
  5464.           Tab       {TAB}
  5465.           Up Arrow  {UP}
  5466.  
  5467.         To enter an Alt, Control, or Shift key combination, precede the
  5468.         desired key with one of the following symbols:
  5469.  
  5470.           Alt       !
  5471.           Control   ^
  5472.           Shift     +
  5473.  
  5474.         For example, to enter Alt-S:
  5475.  
  5476.           SendKey("!S").
  5477.  
  5478.         You may also repeat a key by following it with a space and then
  5479.         the total number of repetitions desired.
  5480.         For example, to move the cursor down 8 lines:
  5481.  
  5482.           SendKey("{DOWN} 8")
  5483.  
  5484.  
  5485.  
  5486.  
  5487.         78
  5488.  
  5489.                                                    WBL FUNCTION REFERENCE
  5490.  
  5491.  
  5492.  
  5493.  
  5494.  
  5495.         Example:
  5496.           ; Start Notepad.  Use *.* for filenames
  5497.           Run("Notepad.exe", "")
  5498.           SendKey("!FO*.*~")
  5499.  
  5500.         It is possible to use SendKey to send keystrokes to a DOS
  5501.         application, but only if you are running Windows in 386 Enhanced
  5502.         mode.  You transfer the keystrokes to the DOS application via the
  5503.         clipboard.  For example:
  5504.  
  5505.           ; run batch file which starts our editor
  5506.           run("edit.bat", "")
  5507.           ; wait 15 seconds for editor to load
  5508.           Delay(15)
  5509.           ; send Alt-F N to the clipboard
  5510.           ClipPut("!FN")
  5511.           ; paste contents of clipboard to DOS window
  5512.           SendKey("!{SP}EP")
  5513.  
  5514.         See Also:
  5515.           SKDebug
  5516.  
  5517.  
  5518.  
  5519.         SKDebug
  5520.  
  5521.         Controls how SendKey works
  5522.  
  5523.         Syntax:
  5524.           Skdebug(mode)
  5525.  
  5526.         Parameters:
  5527.           mode =    @OFF  Keystrokes sent to application.  No debug file
  5528.                     written.  Default mode.
  5529.                     @ON  Keystrokes sent to application.  Debug file
  5530.                     written.
  5531.                     @PARSEONLY  Keystrokes not sent to application.
  5532.                     Debug file written.
  5533.  
  5534.         Returns:
  5535.           (integer) previous SKDebug mode.
  5536.  
  5537.         Note: File C:\SKDEBUG.TXT contains parsed keystrokes
  5538.  
  5539.         Example:
  5540.           Run("notepad.exe", "")
  5541.           SKDebug(@ON)
  5542.           SendKey("!FO*.*~")
  5543.           SKDebug(@OFF)
  5544.  
  5545.         See Also:
  5546.           SendKey
  5547.  
  5548.  
  5549.  
  5550.  
  5551.  
  5552.  
  5553.                                                                        79
  5554.  
  5555.         WBL FUNCTION REFERENCE
  5556.  
  5557.  
  5558.  
  5559.         StrCat
  5560.  
  5561.         Concatenates two or more strings.
  5562.  
  5563.         Syntax:
  5564.           StrCat (string1, string2[, stringN]...)
  5565.  
  5566.         Parameters:
  5567.           "string1", etc =  at least two strings you want to "string"
  5568.                     together (so to speak).
  5569.  
  5570.         Returns:
  5571.           (string)  concatenation of the entire list of input strings.
  5572.  
  5573.         Use this command to stick character strings together, or to
  5574.         format display messages.
  5575.  
  5576.         Errors:
  5577.           2058 "StrCat function syntax error"
  5578.  
  5579.         Example:
  5580.           user = AskLine("Login", "Your Name:", "")
  5581.           Message("Login", StrCat("Hi, ", user))
  5582.           ; note that this will do the same:
  5583.           Message("Login", "Hi, %user%")
  5584.  
  5585.         See Also:
  5586.           StrFill, StrFix, StrTrim
  5587.  
  5588.  
  5589.  
  5590.         StrCmp
  5591.  
  5592.         Compares two strings.
  5593.  
  5594.         Syntax:
  5595.           StrCmp (string1, string2)
  5596.  
  5597.         Parameters:
  5598.           "string1", "string2" =
  5599.                     strings to compare.
  5600.  
  5601.         Returns:
  5602.           (integer) -1, 0, or 1; depending on whether string1 is less
  5603.                     than, equal to, or greater than string2,
  5604.                     respectively.
  5605.  
  5606.         Use this command to determine whether two strings are equal, or
  5607.         which precedes the other in an ASCII sorting sequence.
  5608.         Note:  This command has been included for semantic completeness.
  5609.         The relational operators >, >=, ==, !=, <=, and < provide the
  5610.         same capability.
  5611.  
  5612.  
  5613.  
  5614.  
  5615.  
  5616.  
  5617.  
  5618.         80
  5619.  
  5620.                                                    WBL FUNCTION REFERENCE
  5621.  
  5622.  
  5623.  
  5624.         Example:
  5625.           a = AskLine("STRCMP", "Enter a test line", "")
  5626.           b = AskLine("STRCMP", "Enter another test line", "")
  5627.           c = StrCmp(a, b)
  5628.           c = c + 1
  5629.           d = StrSub("less than   equal to    greater     than", c * 12,
  5630.             12)
  5631.           ; Note that above string is grouped into 12-character chunks.
  5632.           ; Desired chunk is removed with the StrSub statement.
  5633.           Message("STRCMP", "%a% is %d% %b%")
  5634.  
  5635.         See Also:
  5636.           StrICmp, StrIndex, StrLen, StrScan, StrSub
  5637.  
  5638.  
  5639.  
  5640.         StrFill
  5641.  
  5642.         Creates a string filled with a series of characters.
  5643.  
  5644.         Syntax:
  5645.           StrFill (filler, length)
  5646.  
  5647.         Parameters:
  5648.           "filler" =   a string to be repeated to create the return
  5649.                     string.  If the filler string is null, spaces will
  5650.                     be used instead.
  5651.           length =  the length of the desired string.
  5652.  
  5653.         Returns:
  5654.           (string)  character string.
  5655.  
  5656.         Use this function to create a string consisting of multiple
  5657.         copies of the filler string concatenated together.
  5658.  
  5659.         Example:
  5660.           Message("My Stars", StrFill("*", 30))
  5661.  
  5662.         See Also:
  5663.           StrCat, StrFix, StrLen, StrTrim
  5664.  
  5665.  
  5666.  
  5667.         StrFix
  5668.  
  5669.         Pads or truncates a string to a fixed length.
  5670.  
  5671.         Syntax:
  5672.           StrFix (base-string, pad-string, length)
  5673.  
  5674.         Parameters:
  5675.           "base-string" =   string to be adjusted to a fixed length.
  5676.           "pad-string" = appended to "base-string" if needed to fill out
  5677.                     the desired length.  If "pad-string" is null, spaces
  5678.                     are used instead.
  5679.  
  5680.  
  5681.  
  5682.  
  5683.                                                                        81
  5684.  
  5685.         WBL FUNCTION REFERENCE
  5686.  
  5687.  
  5688.  
  5689.           length =  length of the desired string.
  5690.  
  5691.         Returns:
  5692.           (string)  fixed size string.
  5693.  
  5694.         This function "fixes" the length of a string, either by
  5695.         truncating it on the right, or by appending enough copies of pad-
  5696.         string to achieve the desired length.
  5697.  
  5698.         Example:
  5699.           a = StrFix("Henry", " ", 15)
  5700.           b = StrFix("Betty", " ", 15)
  5701.           c = StrFix("George", " ", 15)
  5702.           Message("Spaced Names", StrCat(a, b, c))
  5703.  
  5704.         See Also:
  5705.           StrFill, StrLen, StrTrim
  5706.  
  5707.  
  5708.  
  5709.         StriCmp
  5710.  
  5711.         Compares two strings without regard to case.
  5712.  
  5713.         Syntax:
  5714.           StrICmp (string1, string2)
  5715.  
  5716.         Parameters:
  5717.           "string1", "string2" = strings to compare.
  5718.  
  5719.         Returns:
  5720.           (integer) -1, 0, or 1; depending on whether string1 is less
  5721.                     than, equal to, or greater than string2,
  5722.                     respectively.
  5723.  
  5724.         Use this command to determine whether two strings are equal, or
  5725.         which precedes the other in an ACSII sorting sequence, when case
  5726.         is ignored.
  5727.  
  5728.         Example:
  5729.           a = AskLine("STRICMP", "Enter a test line", "")
  5730.           b = AskLine("STRICMP", "Enter another test line", "")
  5731.           c = StriCmp(a, b)
  5732.           c = c + 1
  5733.           d = StrSub("less than   equal to    greater than", c * 12, 12)
  5734.           ; Note that above string is grouped into 12-character chunks.
  5735.           ; Desired chunk is removed with the StrSub statement.
  5736.           Message("STRICMP", "%a% is %d% %b%")
  5737.  
  5738.         See Also:
  5739.           StrCmp, StrIndex, StrLen, StrScan, StrSub
  5740.  
  5741.  
  5742.  
  5743.  
  5744.  
  5745.  
  5746.  
  5747.  
  5748.         82
  5749.  
  5750.                                                    WBL FUNCTION REFERENCE
  5751.  
  5752.  
  5753.  
  5754.         StrIndex
  5755.  
  5756.         Searches a string for a substring.
  5757.  
  5758.         Syntax:
  5759.           StrIndex (string, sub-string, start, direction)
  5760.  
  5761.         Parameters:
  5762.           "string" =   the string to be searched for a substring.
  5763.           "substring" =  the string to look for within the main string.
  5764.           start =   the position in the main string to begin the search.
  5765.                     The first character of a string is position 1.
  5766.           direction =  the search direction.  @FWDSCAN searches forward,
  5767.                     while @BACKSCAN searches backwards.
  5768.  
  5769.         Returns:
  5770.           (integer) position of "sub-string" within "string";
  5771.                     0 if not found.
  5772.  
  5773.         This function searches for a substring within a "target" string.
  5774.         Starting at the "start" position, it goes forward or backward
  5775.         depending on the value of the "direction" parameter.  It stops
  5776.         when it finds the "substring" within the "target" string, and
  5777.         returns its position.
  5778.  
  5779.         A start position of 0 has special meaning depending on which
  5780.         direction you are scanning.  For forward searches zero indicates
  5781.         the search should start at the beginning of the string.  For
  5782.         reverse searches zero causes it to start at the end of the
  5783.         string.
  5784.  
  5785.         Errors:
  5786.           3100 "StrIndex/StrScan 3rd parameter out of bounds"
  5787.  
  5788.         Example:
  5789.           instr = AskLine("STRINDEX", "Type a sentence:", "")
  5790.           start = 1
  5791.           end = StrIndex(InStr, " ", start, @FWDSCAN)
  5792.           If end == 0 Then Goto error
  5793.           Message("STRINDEX", StrCat("The first word is: ",
  5794.             StrSub(instr, start, end - 1))
  5795.           Exit
  5796.           :error
  5797.           Message("Sorry...", "No spaces found")
  5798.  
  5799.         See Also:
  5800.           StrLen, StrScan, StrSub
  5801.  
  5802.  
  5803.  
  5804.         StrLen
  5805.  
  5806.         Provides the length of a string.
  5807.  
  5808.         Syntax:
  5809.           StrLen (string)
  5810.  
  5811.  
  5812.  
  5813.                                                                        83
  5814.  
  5815.         WBL FUNCTION REFERENCE
  5816.  
  5817.  
  5818.  
  5819.         Parameters:
  5820.           "string" =   any text string.
  5821.  
  5822.         Returns:
  5823.           (integer) length of string.
  5824.  
  5825.         Use this command to determine the length of a string variable or
  5826.         expression.
  5827.  
  5828.         Example:
  5829.           myfile = AskLine("Filename", "File to process:", "")
  5830.           namlen = StrLen(myfile)
  5831.           If namlen > 13 Then Message("", "Filename too long!")
  5832.  
  5833.         See Also:
  5834.           StrFill, StrFix, StrIndex, StrScan, StrTrim
  5835.  
  5836.  
  5837.  
  5838.         StrLower
  5839.  
  5840.         Converts a string to lowercase.
  5841.  
  5842.         Syntax:
  5843.           StrLower (string)
  5844.  
  5845.         Parameters:
  5846.           "string" =   any text string.
  5847.  
  5848.         Returns:
  5849.           (string)  lowercase string.
  5850.  
  5851.         Use this command to convert a text string to lower case.
  5852.  
  5853.         Example:
  5854.           a = AskLine("STRLOWER", "Enter text", "")
  5855.           b = strlower(a)
  5856.           message(a, b)
  5857.  
  5858.         See Also:
  5859.           StrICmp, StrUpper
  5860.  
  5861.  
  5862.  
  5863.         StrReplace
  5864.  
  5865.         Replaces all occurances of a substring with another.
  5866.  
  5867.         Syntax:
  5868.           StrReplace (string, old, new)
  5869.  
  5870.         Parameters:
  5871.           "string" =   string in which to search.
  5872.           "old" =   target substring.
  5873.           "new" =   replacement substring.
  5874.  
  5875.  
  5876.  
  5877.  
  5878.  
  5879.         84
  5880.  
  5881.                                                    WBL FUNCTION REFERENCE
  5882.  
  5883.  
  5884.  
  5885.         StrReplace scans the 'string', searching for occurrences of 'old'
  5886.         and replacing each occurrence with 'new'.  'String' is modified
  5887.         directly.
  5888.  
  5889.         Example:
  5890.           ; Copy highlighted files to clipboard
  5891.           a = FileItemize("")
  5892.           crlf = StrCat(Num2Char(13), Num2Char(10))
  5893.           StrReplace(a, " ", crlf)
  5894.           ClipPut(a)
  5895.  
  5896.  
  5897.  
  5898.         StrScan
  5899.  
  5900.         Searches string for occurrence of delimiters.
  5901.  
  5902.         Syntax:
  5903.           StrScan (string, delimiters, start, direction)
  5904.  
  5905.         Parameters:
  5906.           "string" =   the string that is to be searched.
  5907.           "delimiters" = a string of delimiters to search for within
  5908.                     "string".
  5909.           start =   the position in the main string to begin the search.
  5910.                     The first character of a string is  position 1.
  5911.           direction =  the search direction.  @FWDSCAN searches forward,
  5912.                     while @BACKSCAN searches backwards.
  5913.  
  5914.         Returns:
  5915.           (integer) position of delimiter in string, or 0 if not found.
  5916.  
  5917.         This function searches for delimiters within a target "string".
  5918.         Starting at the "start" position, it goes forward or backward
  5919.         depending on the value of the "direction" parameter.  It stops
  5920.         when it finds any one of the characters in the "delimiters"
  5921.         string within the target "string".
  5922.  
  5923.         Errors:
  5924.           3100 "StrIndex/StrScan 3rd parameter out of bounds"
  5925.  
  5926.         Example:
  5927.           thestr = "123,456.789:abc"
  5928.           start = 1
  5929.           end = StrScan(thestr, ",.:", start, @FWDSCAN)
  5930.           If end == 0 Then Goto error
  5931.           Message("The first parameter", StrSub(thestr, start, end -
  5932.             start + 1))
  5933.           Exit
  5934.           :error
  5935.           Message("Sorry...", "No delimiters found")
  5936.  
  5937.         See Also:
  5938.           StrLen, StrSub
  5939.  
  5940.  
  5941.  
  5942.  
  5943.  
  5944.  
  5945.                                                                        85
  5946.  
  5947.         WBL FUNCTION REFERENCE
  5948.  
  5949.  
  5950.  
  5951.         StrSub
  5952.  
  5953.         Extracts a substring out of an existing string.
  5954.  
  5955.         Syntax:
  5956.           StrSub (string, start, length)
  5957.  
  5958.         Parameters:
  5959.           "string" =   the string from which the substring is to be
  5960.                     extracted.
  5961.           start =   character position within "string" where the sub-
  5962.                     string starts.  (The first character of the string
  5963.                     is at position 1).
  5964.           length =  length of desired substring.  If you specify a
  5965.                     length of zero it will return a null string.
  5966.  
  5967.         Returns:
  5968.           (string)  substring of parameter string.
  5969.  
  5970.         This function extracts a substring from within a "target" string.
  5971.         Starting at the "start" position, it copies up to "length"
  5972.         characters into the substring.
  5973.  
  5974.         Errors:
  5975.           3059 "Illegal Bounds for STRSUB function"
  5976.  
  5977.         Example:
  5978.           a = "My dog has fleas"
  5979.           animal = StrSub(a, 4, 3)
  5980.           Message("STRSUB", "My animal is a %animal%")
  5981.  
  5982.         See Also:
  5983.           StrLen, StrScan
  5984.  
  5985.  
  5986.  
  5987.         StrTrim
  5988.  
  5989.         Removes leading and trailing spaces from a character string.
  5990.  
  5991.         Syntax:
  5992.           StrTrim (string)
  5993.  
  5994.         Parameters:
  5995.           "string" =   a string with unwanted spaces at the beginning
  5996.                     and/or the end.
  5997.  
  5998.         Returns:
  5999.           (string)  string devoid of leading and trailing spaces.
  6000.  
  6001.         Use this function to remove unwanted spaces from the beginning
  6002.         and end of text data.
  6003.  
  6004.  
  6005.  
  6006.  
  6007.  
  6008.  
  6009.         86
  6010.  
  6011.                                                    WBL FUNCTION REFERENCE
  6012.  
  6013.  
  6014.  
  6015.         Example:
  6016.           thefile = AskLine("STRTRIM", "Filename ('exit' cancels)", "")
  6017.           tstexit = StrTrim(StrLower(thefile))
  6018.           If tstexit == "exit" Then Goto cancel
  6019.           ; processing of thefile continues...
  6020.           : cancel
  6021.           Message("Canceled", "...by user request")
  6022.  
  6023.         See Also:
  6024.           StrFill, StrFix, StrLen
  6025.  
  6026.  
  6027.  
  6028.         StrUpper
  6029.  
  6030.         Converts a string to uppercase.
  6031.  
  6032.         Syntax:
  6033.           StrUpper (string)
  6034.  
  6035.         Parameters:
  6036.           "string" =   any text string.
  6037.  
  6038.         Returns:
  6039.           (string)  uppercase string.
  6040.  
  6041.         Use this function to convert a text string to upper case.
  6042.  
  6043.         Example:
  6044.           a = AskLine("STRUPPER", "Enter text","")
  6045.           b = StrUpper(a)
  6046.           message(a, b)
  6047.  
  6048.         See Also:
  6049.           StrICmp, StrLower
  6050.  
  6051.  
  6052.  
  6053.         TextBox
  6054.  
  6055.         Displays a file in a listbox on the screen and returns selected
  6056.         line, if any.
  6057.  
  6058.         Syntax:
  6059.           TextBox (title, filename)
  6060.  
  6061.         Parameters:
  6062.           "title" = listbox title.
  6063.           "filename" = file containing contents of listbox.
  6064.  
  6065.         Returns:
  6066.           (string) =   highlighted string, if any.
  6067.  
  6068.         The TextBox command loads a file into a Windows listbox and
  6069.         displays the listbox to the user.  The command has two primary
  6070.         uses:  First off, it can be used to display multi-line messages
  6071.  
  6072.  
  6073.  
  6074.  
  6075.                                                                        87
  6076.  
  6077.         WBL FUNCTION REFERENCE
  6078.  
  6079.  
  6080.  
  6081.         to the user.  In addition, because of its ability to return a
  6082.         selected line, it may be used as a multiple choice question box.
  6083.         The line highlighted by the user (if any) will be returned to the
  6084.         program.
  6085.  
  6086.         If disk drive and path not are part of the filename,  the current
  6087.         directory will be examined first, and then the DOS path will be
  6088.         searched to find the desired file.
  6089.  
  6090.         Example:
  6091.           ; Display config.sys
  6092.           a = TextBox("Choose a line", "C:\CONFIG.SYS")
  6093.           Display(3, "Chosen line", a)
  6094.  
  6095.         See Also:
  6096.           ItemSelect
  6097.  
  6098.  
  6099.  
  6100.         Version
  6101.  
  6102.         Returns the version number of the currently-running WinBatch
  6103.         language processor.
  6104.  
  6105.         Syntax:
  6106.           Version ( )
  6107.  
  6108.         Returns:
  6109.           (string) =   WinBatch version number.
  6110.  
  6111.         Use this function to determine the version of WinBatch that is
  6112.         running.  It is useful to verify that a batch file generated with
  6113.         the latest version of the language will operate properly on what
  6114.         may be a different machine with a different version of WinBatch
  6115.         installed.
  6116.  
  6117.         Example:
  6118.           a = Version()
  6119.  
  6120.         See Also:
  6121.           Environment, WinVersion
  6122.  
  6123.  
  6124.  
  6125.         WinActivate
  6126.  
  6127.         Activates a previously running window.
  6128.  
  6129.         Syntax:
  6130.           WinActivate (partial-windowname)
  6131.  
  6132.         Parameters:
  6133.           "partial-windowname" =
  6134.                     either an initial portion of, or an entire window
  6135.                     name.  The most-recently used window whose title
  6136.                     matches the name will be activated.
  6137.  
  6138.  
  6139.  
  6140.  
  6141.         88
  6142.  
  6143.                                                    WBL FUNCTION REFERENCE
  6144.  
  6145.  
  6146.  
  6147.         Returns:
  6148.           (integer) @TRUE if a window was found to activate;
  6149.                     @FALSE if no windows were found.
  6150.  
  6151.         Use this command to activate windows for user input.
  6152.  
  6153.         Errors:
  6154.           1045 "WinActivate: Window not found"
  6155.  
  6156.         Example:
  6157.           Run("notepad.exe", "")
  6158.           Run("clock.exe", "")
  6159.           WinActivate("Notepad")
  6160.  
  6161.         See Also:
  6162.           WinCloseNot, WinGetActive, WinShow
  6163.  
  6164.  
  6165.  
  6166.         WinArrange
  6167.  
  6168.         Arranges, tiles, and/or stacks application windows.
  6169.  
  6170.         Syntax:
  6171.           WinArrange (style)
  6172.  
  6173.         Parameters:
  6174.           style =   one of the following:  @STACK, @TILE (or @ARRANGE),
  6175.                     @ROWS, or @COLUMNS.
  6176.         Returns:
  6177.           (integer) always @TRUE.
  6178.  
  6179.         Use this command to rearrange the open windows on the screen.
  6180.         (Any iconized programs are unaffected.)
  6181.  
  6182.         When you specify @ROWS and you have more than four open windows,
  6183.         or if you specify @COLUMNS and you have more than three open
  6184.         windows, WinBatch will revert to @TILE.
  6185.  
  6186.         Example:
  6187.           ; Reveal all windows
  6188.           WinArrange(@TILE)
  6189.  
  6190.         See Also:
  6191.           WinItemize, WinHide, WinIconize, WinPlace, WinShow, WinZoom
  6192.  
  6193.  
  6194.  
  6195.         WinClose
  6196.  
  6197.         Closes an open window.
  6198.  
  6199.         Syntax:
  6200.           WinClose (partial-windowname)
  6201.  
  6202.  
  6203.  
  6204.  
  6205.  
  6206.                                                                        89
  6207.  
  6208.         WBL FUNCTION REFERENCE
  6209.  
  6210.  
  6211.  
  6212.         Parameters:
  6213.           "partial-windowname" =
  6214.                     either an initial portion of, or an entire window
  6215.                     name.  The most-recently used window whose title
  6216.                     matches the name will be closed.
  6217.  
  6218.         Returns:
  6219.           (integer) @TRUE if a window was found to close;
  6220.                     @FALSE if no windows were found.
  6221.  
  6222.         Use this command to close windows.
  6223.         This command will not close the current WinBatch window.  You
  6224.         can, however, call EndSession to end the current Windows session.
  6225.  
  6226.         Errors:
  6227.           1039 "WinClose: Window not found"
  6228.  
  6229.         Example:
  6230.           Run("notepad.exe", "")
  6231.           WinClose("Notepad")
  6232.  
  6233.         See Also:
  6234.           WinCloseNot, WinHide, WinIconize, WinWaitClose
  6235.  
  6236.  
  6237.  
  6238.         WinCloseNot
  6239.  
  6240.         Closes all windows, except those provided as parameters:.
  6241.  
  6242.         Syntax:
  6243.           WinCloseNot (partial-windowname [, partial-windowname]...)
  6244.  
  6245.         Parameters:
  6246.           "partial-windowname" =
  6247.                     either an initial portion of, or an entire window
  6248.                     name.  Any windows whose titles match the partial
  6249.                     names will stay open.
  6250.  
  6251.         Returns:
  6252.           (integer) always @TRUE.
  6253.  
  6254.         Use this command to close all windows except those specifically
  6255.         listed in the parameter strings.
  6256.  
  6257.         At least one partial windowname must be given.  A null-string
  6258.         parameter would match all windows, or in other words close
  6259.         nothing.
  6260.  
  6261.  
  6262.  
  6263.  
  6264.  
  6265.  
  6266.  
  6267.  
  6268.  
  6269.  
  6270.  
  6271.  
  6272.         90
  6273.  
  6274.                                                    WBL FUNCTION REFERENCE
  6275.  
  6276.  
  6277.  
  6278.         Errors:
  6279.           2038 "WinCloseNot Function Syntax error"
  6280.  
  6281.         Example:
  6282.           ; The statement below will close all windows except:
  6283.           ; 1) MS-DOS Executive (starts with 'MS-D')
  6284.           ; 2) Clock  (starts with 'Clo' )
  6285.           WinCloseNot("MS-D", "Clo")
  6286.  
  6287.         See Also:
  6288.           WinItemize, WinClose, WinHide, WinIconize, WinWaitClose
  6289.  
  6290.  
  6291.  
  6292.         WinConfig
  6293.  
  6294.         Returns WIN3 mode flags.
  6295.  
  6296.         Syntax:
  6297.           WinConfig ()
  6298.  
  6299.  
  6300.         Returns the Windows configuration information as a number.  Bits
  6301.         are defined as follows:
  6302.  
  6303.           1     Protected Mode
  6304.           2     80286 CPU
  6305.           4     80386 CPU
  6306.           8     80486 CPU
  6307.           16    Standard Mode
  6308.           32    Enhanced Mode
  6309.           64    8086 CPU
  6310.           128   80186 CPU
  6311.           256   Large PageFrame
  6312.           512   Small PageFrame
  6313.           1024  80x87 Installed
  6314.  
  6315.  
  6316.  
  6317.         WinExist
  6318.  
  6319.         Tells if Window exists.
  6320.  
  6321.         Syntax:
  6322.           WinExist (partialwindowname)
  6323.  
  6324.         Parameters:
  6325.           "partial-windowname" =
  6326.                     either an initial portion of, or an entire window
  6327.                     name.
  6328.  
  6329.         Returns:
  6330.           (integer) @TRUE if a matching window is found.
  6331.                     @FALSE if a matching window is not found.
  6332.  
  6333.         Note: The partial window name you give must match the initial
  6334.         portion of the window name (as appears in the title bar) exactly,
  6335.         including proper case (upper or lower) and punctuation.
  6336.  
  6337.                                                                        91
  6338.  
  6339.         WBL FUNCTION REFERENCE
  6340.  
  6341.  
  6342.  
  6343.         Example:
  6344.           If WinExist("Clock") == @FALSE Then RunIcon("Clock", "")
  6345.  
  6346.  
  6347.  
  6348.         WinGetActive
  6349.  
  6350.         Gets the title of the active window.
  6351.  
  6352.         Syntax:
  6353.           WinGetActive ( )
  6354.  
  6355.         Returns:
  6356.           (string)  title of active window.
  6357.  
  6358.         Use this command to determine which window is currently active.
  6359.  
  6360.         Example:
  6361.           currentwin = WinGetActive()
  6362.  
  6363.         See Also:
  6364.           WinItemize, WinActivate
  6365.  
  6366.  
  6367.  
  6368.         WinHide
  6369.  
  6370.         Hides a window.
  6371.  
  6372.         Syntax:
  6373.           WinHide (partial-windowname)
  6374.  
  6375.         Parameters:
  6376.           "partial-windowname" =
  6377.                     either an initial portion of, or an entire window
  6378.                     name.  The most-recently used window whose title
  6379.                     matches the name will be hidden.
  6380.  
  6381.         Returns:
  6382.           (integer) @TRUE if a window was found to hide;
  6383.                     @FALSE if no windows were found.
  6384.  
  6385.         Use this command to hide windows.  The programs are still running
  6386.         when they are hidden.
  6387.  
  6388.         A partial-windowname of "" hides the current WinBatch window.
  6389.  
  6390.         Errors:
  6391.           1040 "WinHide: Window not found"
  6392.  
  6393.         Example:
  6394.           Run("notepad.exe", "")
  6395.           WinHide("Notepad")
  6396.           WinShow("Notepad")
  6397.  
  6398.         See Also:
  6399.           WinClose, WinIconize, WinPlace
  6400.  
  6401.  
  6402.         92
  6403.  
  6404.                                                    WBL FUNCTION REFERENCE
  6405.  
  6406.  
  6407.  
  6408.         WinIconize
  6409.  
  6410.         Iconizes a window.
  6411.  
  6412.         Syntax:
  6413.           WinIconize (partial-windowname)
  6414.  
  6415.         Parameters:
  6416.           "partial-windowname" =
  6417.                     either an initial portion of, or an entire window
  6418.                     name.  The most-recently used window whose title
  6419.                     matches the name will be iconized.
  6420.  
  6421.         Returns:
  6422.           (integer) @TRUE if a window was found to iconize;
  6423.                     @FALSE if no windows were found.
  6424.  
  6425.         Use this command to turn a window into an icon at the bottom of
  6426.         the screen.
  6427.  
  6428.         A partial-windowname of "" iconizes the current WinBatch window.
  6429.  
  6430.         Errors:
  6431.           1041 "WinIconize: Window not found"
  6432.  
  6433.         Example:
  6434.           Run("clock.exe", "")
  6435.           WinIconize("Clo")   ; partial window name used here
  6436.  
  6437.         See Also:
  6438.           WinClose, WinHide, WinPlace, WinShow, WinZoom
  6439.  
  6440.  
  6441.  
  6442.         WinItemize
  6443.  
  6444.         Returns a tab-delimited list of all open windows.
  6445.  
  6446.         Syntax:
  6447.           WinItemize ( )
  6448.  
  6449.         Returns:
  6450.           (string)  list of all open windows' titles.
  6451.  
  6452.         This function compiles a list of all the open application
  6453.         windows' titles and separates the titles by tabs.  This is
  6454.         especially useful in conjunction with the ItemSelect function,
  6455.         which enables the user to choose an item from such a tab-
  6456.         delimited list.
  6457.  
  6458.         Note this behaves somewhat differently than FileItemize and
  6459.         DirItemize, which create space-delimited lists.  This is because
  6460.         window titles regularly contain embedded spaces.
  6461.  
  6462.  
  6463.  
  6464.  
  6465.  
  6466.  
  6467.                                                                        93
  6468.  
  6469.         WBL FUNCTION REFERENCE
  6470.  
  6471.  
  6472.  
  6473.         Example:
  6474.           ; Find a window
  6475.           allwins = WinItemize()
  6476.           htab = Num2Char(9)
  6477.           mywind = ItemSelect("Windows", allwins, htab)
  6478.           WinActivate(mywind)
  6479.  
  6480.         See Also:
  6481.           DirItemize, FileItemize, ItemSelect
  6482.  
  6483.  
  6484.  
  6485.         WinPlace
  6486.  
  6487.         Places a window anywhere on the screen.
  6488.  
  6489.         Syntax:
  6490.           WinPlace (x-ulc, y-ulc, x-brc, y-brc, partial-windowname)
  6491.  
  6492.         Parameters:
  6493.           x-ulc =   how far from the left of the screen to place the
  6494.                     upper-left corner (0-1000).
  6495.           y-ulc =   how far from the top of the screen to place the
  6496.                     upper-left corner (0-1000).
  6497.           x-brc =   how far from the left of the screen to place the
  6498.                     bottom-right corner (10-1000) or @NORESIZE.
  6499.           y-brc =   how far from the top of the screen to place the
  6500.                     bottom-right corner (10-1000) or @NORESIZE or
  6501.                     @ABOVEICONS.
  6502.           "partial-windowname" =
  6503.                     either an initial portion of, or an entire window
  6504.                     name.  The most-recently used window whose title
  6505.                     matches the name will be moved to the new position.
  6506.  
  6507.         Returns:
  6508.           (integer) @TRUE if a window was found to move;
  6509.                     @FALSE if no windows were found.
  6510.  
  6511.         Use this command to move windows on the screen.  (You cannot,
  6512.         however, move icons or windows that have been maximized to full
  6513.         screen.)
  6514.  
  6515.         The "x-ulc", "y-ulc", "x-brc", and "y-brc" parameters are based
  6516.         on a logical screen that is 1000 points wide by 1000 points high.
  6517.  
  6518.         You can move the window without changing the width and/or height
  6519.         by specifying @NORESIZE for the "x-brc" and/or "y-brc"
  6520.         parameters, respectively.
  6521.  
  6522.         You can fix the bottom of the window to sit just above the line
  6523.         of icons along the bottom of the screen by specifying a "y-brc"
  6524.         of @ABOVEICONS.
  6525.  
  6526.         Some sample parameters:
  6527.  
  6528.           Upper left quarter of the screen:  0, 0, 500, 500
  6529.           Upper right quarter:  500, 0, 500, 1000
  6530.  
  6531.  
  6532.         94
  6533.  
  6534.                                                    WBL FUNCTION REFERENCE
  6535.  
  6536.  
  6537.  
  6538.           Center quarter:  250, 250, 750, 750
  6539.           Lower left eighth:  0, 750, 500, 1000
  6540.  
  6541.         A handy utility program is included with WinBatch, called
  6542.         WinInfo.exe.  This program lets you take an open window that is
  6543.         sized and positioned the way you like it, and automatically
  6544.         create the proper WinPlace statement for you.  It puts the text
  6545.         into the Clipboard, from which you can paste it into your batch
  6546.         code:
  6547.  
  6548.         You'll need a mouse to use WinInfo.  While WinInfo is the active
  6549.         window, place the mouse over the window you wish to create the
  6550.         WinPlace statement for, and press the spacebar.  The new
  6551.         statement will be placed into the Clipboard.  Then press the Esc
  6552.         key to close WinInfo.
  6553.  
  6554.         Errors:
  6555.           1044 "WinPlace: Window not found"
  6556.  
  6557.         Example:
  6558.           WinPlace(0, 0, 200, 200, "Clock")
  6559.  
  6560.         See Also:
  6561.           WinArrange, WinHide, WinIconize, WinShow, WinZoom
  6562.  
  6563.  
  6564.  
  6565.         WinPosition
  6566.  
  6567.         Returns Window position.
  6568.  
  6569.         Syntax:
  6570.           WinPosition (partialwindowname)
  6571.  
  6572.         Parameters:
  6573.           "partial-windowname" =
  6574.                     either an initial portion of, or an entire window
  6575.                     name.
  6576.  
  6577.         Returns:
  6578.           (string)  window coordinates, delimited by commas.
  6579.  
  6580.         Returns the current Window position information for the selected
  6581.         Window.  It returns 4 comma-separated numbers (see WinPlace for
  6582.         details).
  6583.  
  6584.         Example:
  6585.           a = WinPosition("Clock")
  6586.  
  6587.         A return value for the above function might be "0,0,100,100".
  6588.  
  6589.         See Also:
  6590.           WinPlace
  6591.  
  6592.  
  6593.  
  6594.  
  6595.  
  6596.  
  6597.  
  6598.                                                                        95
  6599.  
  6600.         WBL FUNCTION REFERENCE
  6601.  
  6602.  
  6603.  
  6604.         WinShow
  6605.  
  6606.         Shows a window in its "normal" state.
  6607.  
  6608.         Syntax:
  6609.           WinShow (partial-windowname)
  6610.  
  6611.         Parameters:
  6612.           "partial-windowname" =
  6613.                     either an initial portion of, or an entire window
  6614.                     name.  The most-recently used window whose title
  6615.                     matches the name will be shown.
  6616.  
  6617.         Returns:
  6618.           (integer) @TRUE if a window was found to show;
  6619.                     @FALSE if no windows were found.
  6620.  
  6621.         Use this command to restore a window to its "normal" size and
  6622.         position.
  6623.  
  6624.         A partial-windowname of "" restores the current WinBatch window.
  6625.  
  6626.         Errors:
  6627.           1043 "WinShow: Window not found"
  6628.  
  6629.         Example:
  6630.           RunZoom("notepad.exe", "")
  6631.           ; other processing...
  6632.           WinShow("Notepad")
  6633.  
  6634.         See Also:
  6635.           WinArrange, WinHide, WinIconize, WinZoom
  6636.  
  6637.  
  6638.  
  6639.         WinTitle
  6640.  
  6641.         Changes the title of a window.
  6642.  
  6643.         Syntax:
  6644.           WinTitle (partial-windowname, new-name)
  6645.  
  6646.         Parameters:
  6647.           "partial-windowname" =
  6648.                     either an initial portion of, or an entire window
  6649.                     name.  The most-recently used window whose title
  6650.                     matches the name will be shown.
  6651.           "new-name" = the new name of the window.
  6652.  
  6653.         Returns:
  6654.           (integer) @TRUE if a window was found to rename;
  6655.                     @FALSE if no windows were found.
  6656.  
  6657.         Use this command to change a window's title.
  6658.  
  6659.         A partial-windowname of "" refers to the current WinBatch window.
  6660.  
  6661.  
  6662.  
  6663.  
  6664.         96
  6665.  
  6666.                                                    WBL FUNCTION REFERENCE
  6667.  
  6668.  
  6669.  
  6670.         Note:  Some applications may rely upon their window's title
  6671.         staying the same!  It should be used with caution and adequate
  6672.         testing.
  6673.  
  6674.         Example:
  6675.           ; Capitalize title of window
  6676.           htab = Num2Char(9)
  6677.           allwinds = WinItemize()
  6678.           MyWin = ItemSelect("Uppercase Windows", allwinds, htab)
  6679.           WinTitle(mywin, StrUpper(mywin))
  6680.           Drop(htab, allwinds, mywin)
  6681.  
  6682.         See Also:
  6683.           WinItemize
  6684.  
  6685.  
  6686.  
  6687.         WinVersion
  6688.  
  6689.         Provides the version number of the current Windows system.
  6690.  
  6691.         Syntax:
  6692.           WinVersion (level)
  6693.  
  6694.         Parameters:
  6695.           level =   either @MAJOR or @MINOR.
  6696.  
  6697.         Returns:
  6698.           (integer) either major or minor part of the Windows version
  6699.                     number.
  6700.  
  6701.         Use this command to determine which version of Windows is
  6702.         currently running.
  6703.  
  6704.         @MAJOR returns the integer part of the Windows version number;
  6705.         i.e. 1.0, 2.11, 3.0, etc.
  6706.  
  6707.         @MINOR returns the decimal part of the Windows version number;
  6708.         i.e. 1.0, 2.11, 3.0, etc.
  6709.  
  6710.         Example:
  6711.           minorver = WinVersion(@MINOR)
  6712.           majorver = WinVersion(@MAJOR)
  6713.           Message("Windows Version", StrCat(majorver, ".", minorver))
  6714.  
  6715.         See Also:
  6716.           Version
  6717.  
  6718.  
  6719.  
  6720.         WinWaitClose
  6721.  
  6722.         Suspends the batch file execution until a specified window has
  6723.         been closed.
  6724.  
  6725.  
  6726.  
  6727.  
  6728.  
  6729.  
  6730.                                                                        97
  6731.  
  6732.         WBL FUNCTION REFERENCE
  6733.  
  6734.  
  6735.  
  6736.         Syntax:
  6737.           WinWaitClose (partial-windowname)
  6738.  
  6739.         Parameters:
  6740.           "partial-windowname" =
  6741.                     either an initial portion of, or an entire window
  6742.                     name.  WinWaitClose suspends execution until all
  6743.                     matching windows have been closed.
  6744.  
  6745.         Returns:
  6746.           (integer) @TRUE if at least one window was found to wait for;
  6747.                     @FALSE if no windows were found.
  6748.  
  6749.         Use this command to suspend the batch file's execution until the
  6750.         user has finished using a given window and has manually closed
  6751.         it.
  6752.  
  6753.         Example:
  6754.           Run("clock.exe", "")
  6755.           Display(4, "Note", "Close Clock to continue")
  6756.           WinWaitClose("Clock")
  6757.           Message("Continuing...", "Clock closed")
  6758.  
  6759.         See Also:
  6760.           Delay, Yield
  6761.  
  6762.  
  6763.  
  6764.         WinZoom
  6765.  
  6766.         Maximizes a window to full-screen.
  6767.  
  6768.         Syntax:
  6769.           WinZoom (partial-windowname)
  6770.  
  6771.         Parameters:
  6772.           "partial-windowname" =
  6773.                     either an initial portion of, or an entire window
  6774.                     name.  The most-recently used window whose title
  6775.                     matches the name will be shown.
  6776.  
  6777.         Returns:
  6778.           (integer) @TRUE if a window was found to zoom;
  6779.                     @FALSE if no windows were found.
  6780.  
  6781.         Use this command to "zoom" windows to full screen size.
  6782.         A partial-windowname of "" zooms the current WinBatch window.
  6783.  
  6784.         Errors:
  6785.           1042 "WinZoom: Window not found"
  6786.  
  6787.         Example:
  6788.           Run("notepad.exe", "")
  6789.           WinZoom("Notepad")
  6790.           WinShow("Notepad")
  6791.  
  6792.  
  6793.  
  6794.  
  6795.  
  6796.         98
  6797.  
  6798.                                                    WBL FUNCTION REFERENCE
  6799.  
  6800.  
  6801.  
  6802.         See Also:
  6803.           WinHide, WinIconize, WinPlace, WinShow
  6804.  
  6805.  
  6806.  
  6807.         Yield
  6808.  
  6809.         Provides time for other windows to do processing.
  6810.  
  6811.         Syntax:
  6812.           Yield
  6813.  
  6814.         Use this command to give other running windows time to process.
  6815.         This command will allow each open window to process 20 or more
  6816.         messages.
  6817.  
  6818.         Example:
  6819.           ;run Excel and give it some time to start up...
  6820.           sheet = AskLine ("Excel", "File to run:", "")
  6821.           run("Excel.exe", sheet)
  6822.           yield
  6823.           yield
  6824.           yield
  6825.  
  6826.         See Also:
  6827.           Delay
  6828.  
  6829.  
  6830.  
  6831.  
  6832.  
  6833.  
  6834.  
  6835.  
  6836.  
  6837.  
  6838.  
  6839.  
  6840.  
  6841.  
  6842.  
  6843.  
  6844.  
  6845.  
  6846.  
  6847.  
  6848.  
  6849.  
  6850.  
  6851.  
  6852.  
  6853.  
  6854.  
  6855.  
  6856.  
  6857.  
  6858.                                                                        99
  6859.  
  6860.         APPENDIX A    Predefined Constants
  6861.  
  6862.  
  6863.  
  6864.  
  6865.                                    APPENDIX A
  6866.  
  6867.                               Predefined Constants
  6868.  
  6869.         WBL provides you with a number of predefined integer constants to
  6870.         help make your batch files more mnemonic:
  6871.  
  6872.         Logical Conditions               String Handling
  6873.  
  6874.         @FALSE                           @FWDSCAN
  6875.         @NO                              @BACKSCAN
  6876.         @OFF
  6877.         @TRUE                            Menu Handling
  6878.         @YES
  6879.         @ON                              @ENABLE
  6880.                                          @DISABLE
  6881.         Window Arranging                 @UNCHECK
  6882.                                          @CHECK
  6883.         @NORESIZE
  6884.         @ABOVEICONS                      System Control
  6885.         @STACK
  6886.         @ARRANGE                         @MAJOR
  6887.         @TITLE                           @MINOR
  6888.         @ROWS
  6889.         @COLUMNS                         Error Handling
  6890.  
  6891.                                          @CANCEL
  6892.                                          @NOTIFY
  6893.                                          @OFF
  6894.  
  6895.                                          Keyboard Status
  6896.  
  6897.                                          @SHIFT
  6898.                                          @CTRL
  6899.  
  6900.  
  6901.  
  6902.  
  6903.  
  6904.  
  6905.  
  6906.  
  6907.  
  6908.  
  6909.  
  6910.  
  6911.  
  6912.  
  6913.  
  6914.  
  6915.  
  6916.  
  6917.  
  6918.  
  6919.  
  6920.  
  6921.  
  6922.  
  6923.  
  6924.         100
  6925.  
  6926.                                                      APPENDIX B    Errors
  6927.  
  6928.  
  6929.  
  6930.  
  6931.                                    APPENDIX B
  6932.  
  6933.                                      Errors
  6934.  
  6935.         If the current error mode is @CANCEL (the default), any WBL
  6936.         errors encountered while processing a batch file cause the item
  6937.         to be canceled with an error message.
  6938.  
  6939.  
  6940.         Minor Errors
  6941.  
  6942.         Minor errors are ignored if the current error mode has been set
  6943.         to @OFF.  If the error mode is @NOTIFY the user has the option of
  6944.         continuing with the batch file or canceling it.
  6945.  
  6946.         1006 File Copy/Move: No matching files found
  6947.         1017 File Delete: No matching files found
  6948.         1018 File Delete: Delete Failed
  6949.         1024 File Rename: No matching files found
  6950.         1025 File Rename: Rename failed
  6951.         1028 LogDisk: Requested drive not online
  6952.         1029 DirMake: Dir not created
  6953.         1030 DirRemove: Dir not removed
  6954.         1031 DirChange: Dir not found/changed
  6955.         1039 WinClose: Window not found
  6956.         1040 WinHide: Window not found
  6957.         1041 WinIconize: Window not found
  6958.         1042 WinZoom: Window not found
  6959.         1043 WinShow: Window not found
  6960.         1044 WinPlace: Window not found
  6961.         1045 WinActivate: Window not found
  6962.  
  6963.  
  6964.         Moderate Errors
  6965.  
  6966.         If the error mode is @NOTIFY or @OFF, the user has the option of
  6967.         continuing with the batch file or canceling it.
  6968.  
  6969.         2002 File Copy/Move: 'From' file illegal
  6970.         2003 File Copy/Move: 'To'   file illegal
  6971.         2004 File Copy/Move: Cannot copy/move wildcards into fixed root
  6972.         2005 File Copy/Move: Cannot copy/move wildcards into fixed
  6973.              extension
  6974.         2007 File Move: Unable to rename source file
  6975.         2015 File Move:  Unable to remove source file
  6976.         2016 File Delete: File name illegal
  6977.         2019 File Rename: 'From' file illegal
  6978.         2020 File Rename: 'To' file illegal
  6979.         2021 File Rename: Attempt to rename across drive boundary. - Use
  6980.              MOVE instead.
  6981.         2022 File Rename: Cannot rename wildcards into a fixed filename
  6982.              root
  6983.         2023 File Rename: Cannot rename wildcards into a fixed filename
  6984.              extension
  6985.  
  6986.  
  6987.  
  6988.  
  6989.                                                                       101
  6990.  
  6991.         APPENDIX B    Errors
  6992.  
  6993.  
  6994.  
  6995.         2038 WinCloseNot Function Syntax error
  6996.         2058 StrCat function syntax error
  6997.         2060 Average function syntax error
  6998.  
  6999.  
  7000.         Fatal Errors
  7001.  
  7002.         Fatal errors cause the current batch file to be canceled with an
  7003.         error message, regardless of the error mode in effect.  (We show
  7004.         the error codes here for consistency, but in practice you will
  7005.         never be able to call LastError after a fatal error.)
  7006.  
  7007.         3008 File Copy/Move: 'From' file open error
  7008.         3011 File Copy/Move: 'From' file length error
  7009.         3012 File Copy/Move: No room left on disk.  Out of space??
  7010.         3013 File Copy/Move: 'To' file open error
  7011.         3014 File Copy/Move: I/O Error
  7012.         3026 LogDisk: Illegal disk drive
  7013.         3027 LogDisk: DOS reports no disks!!  ???
  7014.         3034 Clipboard owned by another app.  Cannot open.
  7015.         3035 Clipboard does not contain text for ClipAppend.
  7016.         3036 Clipboard cannot hold that much text (>64000 bytes)
  7017.         3037 Unable to allocate memory for clipboard.  Close some
  7018.              applications
  7019.         3046 Internal Error 3046. Function not defined
  7020.         3047 Variable name over 30 chars. Too Long
  7021.         3048 Substitution %Variable% not followed by a % (Use %% for %)
  7022.         3049 No variables exist??!!
  7023.         3050 Undefined variable
  7024.         3051 Undefined variable or function
  7025.         3052 Uninitialized variable or undefined function
  7026.         3053 Character string too long (>256 chars??)
  7027.         3054 Unrecognizable item found on line
  7028.         3055 Variable name is over 30 chars. Too Long
  7029.         3056 Variable could not be converted to string
  7030.         3057 Variable could not be converted to integer
  7031.         3059 Illegal Bounds for StrSub function
  7032.         3061 Illegal Syntax
  7033.         3062 Attempt to divide by zero
  7034.         3063 Internal Error 3063. Binary op not found
  7035.         3064 Internal Error 3064. Unary op not found
  7036.         3065 Unbalanced Parenthesis
  7037.         3066 Wrong Number of Arguments in Function
  7038.         3067 Function Syntax. Opening parenthesis missing.
  7039.         3068 Function Syntax. Illegal delimiter found.
  7040.         3069 Illegal assignment statement. (Use == for equality testing)
  7041.         3070 Internal error 3070.  Too many arguments defined.
  7042.         3071 Missing or incomplete statement
  7043.         3074 Expression continues past expected end.
  7044.         3081 FileRead: Invalid file handle
  7045.         3082 FileRead: File not currently open
  7046.         3084 FileWrite: Invalid file handle
  7047.         3085 FileWrite: File not currently open
  7048.         3087 FileRead:  File not open for reading
  7049.  
  7050.  
  7051.  
  7052.  
  7053.  
  7054.         102
  7055.  
  7056.                                                      APPENDIX B    Errors
  7057.  
  7058.  
  7059.  
  7060.         3088 FileRead: Attempt to read past end of file
  7061.         3089 FileWrite: File not open for writing
  7062.         3095 Compare could not be resolved into a integer or string
  7063.              compare
  7064.         3096 Memory allocation failure.  Out of memory for string storage
  7065.         3097 Memory allocation failure.  Out of memory for variable
  7066.              storage
  7067.         3098 Internal error, NULL pointer passed to xstrxxx subroutines
  7068.         3100 StrIndex/StrScan 3rd parameter out of bounds
  7069.         3101 Substituted line too long. (> 256 characters)
  7070.         3102 Drop: Can only drop variables
  7071.         3103 IsDefined: Attempting to test non-variables item
  7072.         3107 Run:  Filetype is not COM, EXE, PIF or BAT
  7073.         3108 FileItemize: Unable to lock file info segment
  7074.         3109 FileItemize: Unable to unlock file info segment
  7075.         3110 FileItemize: Unable to lock file index segment
  7076.         3111 FileItemize: Unable to unlock file index segment
  7077.         3112 FileSize:  File Not Found
  7078.         3113 FileSize:  Filelength I/O Error
  7079.         3114 FileSize:  Buffer Overrun Error
  7080.         3115 FileDelete: Buffer Overrun Error
  7081.         3116 FileRename: Buffer Overrun Error
  7082.         3117 FileCopyMove: Buffer Overrun Error
  7083.         3118 FileCopyMove: Destination file same as source
  7084.  
  7085.  
  7086.  
  7087.  
  7088.  
  7089.  
  7090.  
  7091.  
  7092.  
  7093.  
  7094.  
  7095.  
  7096.  
  7097.  
  7098.  
  7099.  
  7100.  
  7101.  
  7102.  
  7103.  
  7104.  
  7105.  
  7106.  
  7107.  
  7108.  
  7109.  
  7110.  
  7111.  
  7112.  
  7113.  
  7114.  
  7115.  
  7116.  
  7117.  
  7118.                                                                       103
  7119.  
  7120.                                                                     Index
  7121.  
  7122.  
  7123.  
  7124.  
  7125.                                      Index
  7126.  
  7127.                                            minor  101
  7128.         A                                  moderate  101-102
  7129.         Abs  36,40                         see also   Debug,
  7130.         AskLine  12,32,40-41                   ErrorMode, LastError
  7131.         AskYesNo  12,32,41               Exclusive  37,55
  7132.         Average  36,41-42                Execute  37,54
  7133.                                          Exit  37,54-55
  7134.         B
  7135.         batch files                      F
  7136.          error handling  31-32           File Management
  7137.          statement summary  32-37          in WBL  32-33
  7138.          statements  37-100              FileClose  32,55-56
  7139.          WBL language components  27-    FileCopy  17,32,55-56
  7140.          31                              FileDelete  17,32,56-57
  7141.         Beep  12,32,13                   FileExist  17,32,57-58
  7142.                                          FileExtension  33,58
  7143.         C                                FileItemize  20,33,58-59
  7144.         Call  36,42                      FileLocate  33,59-60
  7145.         CallExt  36,42-43                FileMove  33,60
  7146.         Char2Num  35,42-43               FileOpen  33,60-61
  7147.         ClipAppend  36,43-44             FilePath  33,61
  7148.         ClipGet  36,44-45                FileRead  33,61-62
  7149.         ClipPut  36,45                   FileRename  17,33,60-63
  7150.         Comments  30                     FileRoot  33,63
  7151.         Constants  27-28                 FileSize  33,63-64
  7152.          predefined  27-28               FileWrite  33,64
  7153.  
  7154.         D                                G
  7155.         DateTime  36,45-46               Goto  37,64
  7156.         Debug  36,46-47
  7157.         Delay  13,36,47                  I
  7158.                      Identifiers  28
  7159.         DirChange  16,33,47-48           If_Then  37,64-65
  7160.         Directory Management             IgnoreInput  37,65
  7161.          in WBL  33                      IniRead  37,64-66
  7162.         DirGet  16,33,48                 IniReadPvt  37,66
  7163.         DirHome  33,48-49                IniWrite  37,66-67
  7164.         DirItemize  21,33,49             IniWritePvt  37,67
  7165.         DirMake  33,49-50                IsDefined  37,67-68
  7166.         DirRemove  33,50                 IsKeyDown  37,68
  7167.         DiskFree  33,50-51               IsLicensed  37,68-69
  7168.         Display  12,32,51                IsNumber  35,68-69
  7169.         DOSVersion  36,51-52             ItemSelect  20,32,69-70
  7170.         Drop  36,51-52
  7171.                                          K
  7172.         E                                Keywords  28
  7173.         EndSession  16,36,52-53
  7174.         Environment  24,36,53            L
  7175.         ErrorMode  18,36,19              LastError  37,70-71
  7176.         Errors  31-32,101-107            LogDisk  33,71
  7177.          fatal  102-107
  7178.  
  7179.  
  7180.  
  7181.  
  7182.                                                                       105
  7183.  
  7184.  
  7185.  
  7186.  
  7187.  
  7188.                                          StrIndex  35,83
  7189.         M                                StrLen  35,83-84
  7190.         Max  36,71-72                    StrLower  35,84
  7191.         Message  12,32,72                StrReplace  35,84-85
  7192.         Microsoft Windows                StrScan  35,84-86
  7193.          date & time formatting  45      StrSub  35,86
  7194.          determining the version         StrTrim  35,86-87
  7195.          37,97                           StrUpper  35,87
  7196.          ending the session  52          Substitution  30-31
  7197.         Min  36,72-73                      and StrCat  78-80
  7198.  
  7199.         N                                T
  7200.         Num2Char  22,35,72-73            TextBox  32,87-88
  7201.  
  7202.         O                                V
  7203.         Operators  28-29                 Variables  28
  7204.          Precedence  29                  Version  37,88
  7205.  
  7206.         P                                W
  7207.         ParseData  35,73-74              WinActivate  14,34,88-89
  7208.         Pause  12,32,73-74               WinArrange  34,89
  7209.                                          WinClose  14,34,89-90
  7210.         R                                WinCloseNot  14,34,90-91
  7211.         Random  36,74                    WinConfig  34,91
  7212.         Registration  109                Window Management
  7213.         Return  37,74-75                   in WBL  33-34
  7214.         Run  11,34,74-75                 WinExist  15,34,91-92
  7215.         RunHide  34,75-76                WinGetActive  34,91-92
  7216.         RunIcon  11,34,76-77             WinHide  34,92-93
  7217.         Running programs                 WinIconize  13,34,93
  7218.          in WBL  34-35                   WinItemize  34,93-94
  7219.         RunZoom  11,35,77-78             WinPlace  34,94-95
  7220.                                          WinPosition  34,95
  7221.         S                                WinShow  13,34,95-96
  7222.         SendKey  24,37,78-79             WinTitle  34,96-97
  7223.         SKDebug  37,79                   WinVersion  37,97
  7224.         Statements  30                   WinWaitClose  15,34,97-98
  7225.          reference  37-100               WinZoom  13,34,98-99
  7226.         StrCat  23,35,78-80
  7227.         StrCmp  35,80-81                 Y
  7228.         StrFill  35,81                   Yield  37,99
  7229.         StrFix  35,81-82
  7230.         StrICmp  35,82-83
  7231.  
  7232.  
  7233.  
  7234.  
  7235.  
  7236.  
  7237.  
  7238.  
  7239.  
  7240.  
  7241.  
  7242.  
  7243.  
  7244.  
  7245.  
  7246.         106
  7247.  
  7248.  
  7249.  
  7250.  
  7251.  
  7252.                                    I want my OWN copy
  7253.                                       of WinBatch!
  7254.                                    Please send it to:
  7255.  
  7256.  
  7257.  
  7258.           Company:__________________________________________________________
  7259.  
  7260.              Name:__________________________________________________________
  7261.  
  7262.           Address:__________________________________________________________
  7263.  
  7264.              City:_____________________________St:__________Zip:____________
  7265.  
  7266.  
  7267.             Phone:(_____)___________________  Country: _____________________
  7268.  
  7269.  
  7270.  
  7271.                          ____WinBatch(es) @$69.95 ea.:____________
  7272.  
  7273.           Foreign air shipping (except Canada) @$9.50:____________
  7274.  
  7275.                                                 Total:____________
  7276.  
  7277.           Please enclose a check payable to Wilson WindowWare; or you may use
  7278.           Visa, Master Card, or EuroCard.  For charge cards, please enter
  7279.           the information below:
  7280.  
  7281.           Card number:   __ __ __ __-__ __ __ __-__ __ __ __-__ __ __ __
  7282.           Expiration date: _______/______
  7283.  
  7284.           Signature:_________________________________________________________
  7285.  
  7286.  
  7287.                Send to:  Wilson WindowWare
  7288.                           2701 California Ave SW #212
  7289.                           Seattle, WA 98116
  7290.                           USA
  7291.  
  7292.                or call:     (800) 762-8383
  7293.                             (206) 935-7129  (fax)
  7294.  
  7295.                         (Please allow 2 to 4 weeks for delivery)
  7296.